/* From https://medium.com/puzzle-sphere/test-your-intelligence-iq-puzzle-only-1-people-can-solve-09390c100c19 """ 12 4 7 5 5 1 \ / \ / \ / 3 2 ? / \ / \ / \ 1 3 3 9 2 7 Here, you have three sets of numbers arranged in a cross-like pattern. Each set has a central number surrounded by four numbers. You have to find the missing number in the third set by identifying the hidden pattern in the first two sets. [ A B \ / E / \ C D ] """ With the assumption that all numbers should be used (unique_vars_all=true) AllGood: [program = (A + D) / (B + C),res = 4.0,count = 951] [program = (D + A) / (B + C),res = 4.0,count = 893] [program = (D + A) / (C + B),res = 4.0,count = 872] [program = (A + D) / (C + B),res = 4.0,count = 867] resultMap = [4.0 = 4] However, there are some other solutions (without that assumption): [program = B - C,res = -1,count = 1830] [program = C + B + (C - C - (D - C)),res = -2,count = 1] */ data(puzzle8,Data,Vars,Unknown,Ops,Constants,MaxSize,Params) :- Data = [[[12,4,1,3],3], [[7,5,3,9],2] ], Vars = ['A','B','C','D'], Unknown = [5,1,2,7], Ops = [+,-,*,/], Constants = [], MaxSize = 5, Params = new_map([init_size=1000, unique_vars_all=true, % remove_similar=true, num_gens=1000 ]).