/* https://puzzles9.com/puzzles/number-sequence-puzzles-with-answers/ Puz1057 """ 2 8 4 9 3 7 6 9 6 8 3 ? Answer : 4 Calculate the difference of numbers in each row. it follows a particular sequence like 6,5,4,3,2,1. 8 – 2 = 6 9 – 4 = 5 7 – 3 = 4 9 – 6 = 3 8 – 6 = 2 4 – 3 = 1 So, answer is 4. """ Since there are both "6 9" and "6 8" in the data, we cannot use the simple representation. Let's test the extended variant: 0 0 2 8 2 8 4 9 4 9 3 7 3 7 6 9 6 9 6 8 6 8 3 ? Nope. However, it works if we add an index to each row (1..6): 1 2 8 2 4 9 3 3 7 4 6 9 5 6 8 6 3 ? maxCount = 3 code = ((B + 7) - A) = [[[1,2],8],[[2,4],9],[[3,3],7],[[4,6],9],[[5,6],8]] = [[6,3] = 4] */ data(puz1057,Data,Vars,Unknown,Ops,Constants,MaxC) :- % Data = [ % [[0,0,2],8], % [[2,8,4],9], % [[4,9,3],7], % [[3,7,6],9], % [[6,9,6],8] % ], Data = [ [[1,2],8], [[2,4],9], [[3,3],7], [[4,6],9], [[5,6],8] ], Unknown = [6,3], Vars = ["A","B","C"], Ops = new_map([infix=["+","-"] ]), Constants = 1..10, MaxC = 3.