/* https://puzzles9.com/puzzles/number-sequence-puzzles-with-answers/ Puz253 """ 5 _ 4 7 _ 1 _ 2 _ _ 5 _ 11 _ 4 13 _ 3 ?? _ 4 _ 4 _ 20 _ 4 """ Encoded as E _ A _ B _ C _ D These solutions are probably not correct since all values are not used: maxCount = 3 code = ((C - B) - A) = [[[4,2,11,4],5],[[1,5,13,3],7]] = [[4,4,20,4] = 12] code = (B + (D - 1)) = [[[4,2,11,4],5],[[1,5,13,3],7]] = [[4,4,20,4] = 7] Adding the "use_all_variables" flag gives this solution: code = ((B * (A + D)) - C) = [[[4,2,11,4],5],[[1,5,13,3],7]] = [[4,4,20,4] = 12] The intended solution: """ Answer : 12 In each box, sum of numbers in first column divided by sum of numbers in third column gives middle number in second column. (5+11) ÷ (4+4) = 2 (7+13) ÷ (1+3) = 5 (20+12) ÷ (4+4) = 4 So, answer is 12. """ */ data(puz253,Data,Vars,Unknown,Ops,Constants,MaxC) :- Matrix = [ [4,2,11,4,5], [1,5,13,3,7], [4,4,20,4,_] ], Ops = new_map([infix=["+","-","*"] ]), Constants = 1..1, MaxC = 6, get_global_map().put("use_all_variables",true), (nl, make_data_matrix(Matrix,Data,Unknown,Vars) ; nl, make_data_matrix(Matrix.transp,Data,Unknown,Vars) ).