/* https://puzzles9.com/puzzles/number-sequence-puzzles-with-answers/ Puz254 """ 5 6 7 4 9 2 4 8 1 6 7 5 4 7 1 6 1 3 5 8 4 2 6 ? 6 Answer : 3 In the above puzzle, in each row , treat first two digits as one number and also last two digits as one number. subtract last number from first number to get middle number. 56 – 49 = 7 24 – 16 = 8 75 – 71 = 4 61 – 58 = 3 42 – 36 = 6 So, answer is 3. """ We rearrange to get the unknown last: 5 6 7 9 4 2 4 8 6 1 7 5 4 1 7 6 1 3 8 5 4 2 6 6 ? This representation seems to be too hard. After about 50 minutes, still no solution is found. Here's the last generation before I aborted the run: """ gen = 32591 results_best = [[0.034522293124594,(A - C / C) * 1 + 5 / (D * D / (1 / 8) + (C - A))],[0.034522293124594,8 + (A - (10 - 1)) + 5 / (D * D / (1 / 8) + (C - A))],[0.034522293124594,A + (8 - 9) + 5 / (D * D / (1 / 8) + (C - A))],[0.034522293124594,3 - 4 + A + 5 / (D * D / (1 / 8) + (C - A))],[0.034522293124594,7 - 8 + A + 5 / (D * D / (1 / 8) + (C - A))],[0.034522293124594,5 - (6 - A) + 5 / (D * D / (1 / 8) + (C - A))],[0.034522293124594,7 - (8 - A) + 5 / (D * D / (1 / 8) + (C - A))],[0.034522293124594,9 - (10 - A) + 5 / (D * D / (1 / 8) + (C - A))],[0.034522293124594,A - 1 + 5 / (D * D / (1 / 8) + (C - A))],[1.2,A - 1 + (C / 10 - (D - 2) / 10)]] good = [] """ See below for an approach that's a little better. */ /* data(puz254,Data,Vars,Unknown,Ops,Constants,MaxSize,Params) :- Matrix = [ [5,6,7,9,4], [2,4,8,6,1], [7,5,4,1,7], [6,1,3,8,5], [4,2,6,6,_] ], % Ops = [+,-,*,/], Ops = [+,-,*,/,to_num2], Constants = 1..10, make_data_matrix(Matrix,Data,Unknown,Vars), % make_data_matrix(Matrix.transp,Data,Unknown,Vars), MaxSize = 11, Params = new_map(). */ /* A simpler variant. Let's simplify the problem a little and make the mid column the unknown instead: 5 6 4 9 7 2 4 1 6 8 7 5 7 1 4 6 1 5 8 3 4 2 3 6 ? For this simple version we find these solutions. * With to_num2/2 [program = to_num2(A - C,B - D),res = 6,count = 1] * Without to_num2/2 it's quite hard to find a solution program = C - (A - 6) + 3 + (C * (A - (3 + 4)) + (B + (D - (C + 4)))),res = 0,count = 1] (simplifies to 5 - A + B + (-7 + A) C + D ) */ data(puz254,Data,Vars,Unknown,Ops,Constants,MaxSize,Params) :- Data = [ [[5,6,4,9],7], [[2,4,1,6],8], [[7,5,7,1],4], [[6,1,5,8],3] ], Unknown = [4,2,3,6], Vars = ['A','B','C','D'], % Ops = [+,-,*], Ops = [+,-,*,to_num2], Constants = 1..10, MaxSize = 11, Params = new_map([init_size=1000,show_best=20]).