/* Squares https://puzzles9.com/puzzles/number-sequence-puzzles-with-answers/ Puz1059 """ 13 5 12 4 5 20 3 5 16 4 11 5 20 4 7 ? Answer : 8 In each rectangle, multiply first row numbers and subtract sum of numbers in second row from it. Result of each rectangle should be 40. (13*5)-(5+20) = 40 (12*4)-(3*5) = 40 (16*4)-(20+4) = 40 (11*5)-(7+8)= 40 So, answer is 8. """ Here we test two different representation from the data matrix [[13,5,5,20], [12,4,3,5], [16,4,20,4], [11,5,7,_] ] * Representation 1: data = [[[13,5,5],20], [[12,4,3],5], [[16,4,20],4]] Some solutions: [program = A * B - 8 - (4 + (32 - 4)) - C,res = 8,count = 1] [program = B * A - (8 + (32 + 1 * C)),res = 8,count = 1] [program = ((C * A - (A + 32)) mod 8 + 1) * ((32 + 32 - (C - 16 - B * A)) mod 8),res = 0,count = 1] [program = B * A mod (32 + C) - 8,res = 8,count = 1] * Representation 2: data = [[[13,12,16],11], [[5,4,4],5], [[5,3,20],7]] [program = 32 mod (C + (4 + 1)),res = 5,count = 8] [program = (16 + A) mod (C - 2) - (16 mod A - A),res = 4,count = 1] [program = 8 * C mod ((A + C) mod 16),res = 0,count = 1] */ data(squares,Data,Vars,Unknown,Ops,Constants,MaxSize,Params) :- Matrix = [[13,5,5,20], [12,4,3,5], [16,4,20,4], [11,5,7,_] ], % Ops = [+,*,-], Ops = [+,*,-,mod], Constants = [1,2,4,8,16,32], make_data_matrix(Matrix,Data,Unknown,Vars), % make_data_matrix(Matrix.transp,Data,Unknown,Vars), MaxSize = 5, Params = new_map([init_size=1000]).