/* Puzzle From the Jchat group: """ A friend sent this puzzle to me as a paper and pencil puzzle. I converted it to a J verb. See if you can write the fun verb yourself. Input is always three single-digit integers... fun 5 3 2 151022 fun 9 2 4 183623 fun 8 6 3 482419 fun 5 4 5 202521 fun 7 2 5 ??? """ According to a later comment the answer should be (a*b*10000)+(a*c*100)+(a*b+c)-b, but this cannot be correct: Picat> [A,B,C] = [5,3,2], X = (A*B*10000)+(A*C*100)+(A*B+C)-B X = 151014 Picat> [A,B,C] = [9,2,4], X = (A*B*10000)+(A*C*100)+(A*B+C)-B X = 183620 Picat> [A,B,C] = [8,6,3], X = (A*B*10000)+(A*C*100)+(A*B+C)-B X = 482445 Picat> [A,B,C] = [5,4,5], X = (A*B*10000)+(A*C*100)+(A*B+C)-B X = 202521 Picat> [A,B,C] = [7,2,5], X = (A*B*10000)+(A*C*100)+(A*B+C)-B X = 143517 It took a while: [program = C + (C * A * 100 - B) + (10000 * B + B) * A,res = 143517,count = 1] Cf puzzle.conf */ data(puzzle,Data,Vars,Unknown,Ops,Constants,MaxSize,Params) :- Data = [ % [[5,3,2],151022], % [[9,2,4],183623], % [[8,6,3],482419], % [[5,4,5],202521] % corrected version [[5,3,2],151014], % 151014 - 151022 = -8 [[9,2,4],183620], % 183620 - 183623 = -3 [[8,6,3],482445], % 482445 - 482419 = -26 [[5,4,5],202521] % 202521 - 202521 = 0 ], Ops = [+,-,*], Constants = [1,10,100,1000,10000], % let's cheat a little :-) % Constants = 1..10, Unknown = [7,2,5], Vars = ['A','B','C'], MaxSize = 11, Params = new_map([% init_fun=$(('A'*'B'*10000)+('A'*'C'*100)+('A'*'B'+'C')-'B'), init_size=1000 ]).