/* https://puzzles9.com/puzzles/number-sequence-puzzles-with-answers/ Puz243 """ 5 2 3 4 2 3 12 6 6 8 8 13 6 5 11 18 6 ?? """ Encoded as A B C D E F * Representation 1 data = [ [[5,2,3,12,6],6], [[4,2,3,8,8],13]] unknown = [6,5,11,18,6] [program = E + E - 9 + (E + (B - A)),res = 8,count = 1] [program = (7 - 6) * E + E - (D - A - 1),res = 1,count = 1] [program = 1 + (A + E - (D - E)),res = 1,count = 1] [program = 10 - A - (D - (E + 7)),res = -1,count = 1] [program = E * E / 4 - C,res = -2.0,count = 1] [program = E - (A + D - 4 * 6) + (9 - to_num2(C,2) / B),res = -7.399999999999999,count = 1] [program = to_num2((1 + 9) / A - B,E),res = -27.333333333333329,count = 1] This is probably not the intended solution. * Representation 2 With stop_criteria=generations and num_gens=1800: gen = 1192 (time: 50.862s) results_best = [[8.362505623031939,6 - to_num2(A,2) / (7 + A) + A / (B / A)]] The intended solution: """ ANSWER : 21 In each grid, add up the 4 numbers at the corners and write the result downwards in the center column. in first rectangle, 5+3+12+6 = 26 in last rectangle, 6+11+18+21 = 56 """ But that was too hard for this program... */ data(puz243,Data,Vars,Unknown,Ops,Constants,MaxSize,Params) :- Matrix = [[ 5, 2, 3,12, 6, 6], [ 4, 2, 3, 8, 8,13], [ 6, 5,11,18, 6, _] ], % make_data_matrix(Matrix,Data,Unknown,Vars), % Representation 1 make_data_matrix(Matrix.transp,Data,Unknown,Vars), % Representation 2 Ops = [+,-,*,/,to_num2,to_num3], Constants = 1..10, MaxSize = 9, Params = new_map([ stop_criteria=generations, num_gens=1800 ]).