/* https://puzzles9.com/puzzles/number-sequence-puzzles-with-answers/ Puz1060 """ 2 11 20 4 9 32 7 8 49 4 10 ? Answer : 36 Multiply first two numbers in each row and subtract first number from the product to get third number in that row. (2*11)-2 = 20 (4*9)-4 = 32 (7*8)-7 = 49 (4*10)-4 = 36 So, answer is 36. """ Two representations, the first is the intended one. * First representation data = [[[2,11],20], [[4,9],32], [[7,8],49]] vars = [A,B] unknown = [4,10] maxCount = 3 code = (A * (B - 1)) = [[[2,11],20],[[4,9],32],[[7,8],49]] = [[4,10] = 36] code = ((A * B) - A) = [[[2,11],20],[[4,9],32],[[7,8],49]] = [[4,10] = 36] code = ((B * A) - A) = [[[2,11],20],[[4,9],32],[[7,8],49]] = [[4,10] = 36] * Second representation data = [[[2,4,7],4], [[11,9,8],10]] vars = [A,B,C] unknown = [20,32,49] ops = (map)[infix = [+,*,-]] constants = [1,2,4,8,16,32] maxC = 6 maxCount = 5 code = (B + (C + (1 - 8))) = [[[2,4,7],4],[[11,9,8],10]] = [[20,32,49] = 74] */ data(puz1060,Data,Vars,Unknown,Ops,Constants,MaxC) :- Matrix = [[2,11,20], [4,9,32], [7,8,49], [4,10,_] ], Ops = new_map([infix=["+","*","-"] ]), Constants = [1,2,4,8,16,32], ( nl, make_data_matrix(Matrix,Data,Unknown,Vars), MaxC = 4 ; nl, make_data_matrix(Matrix.transp,Data,Unknown,Vars), MaxC = 6 ).