/* http://www.borrett.id.au/computing/petals-j.htm See the Bill Gates story about this puzzle: http://www.borrett.id.au/computing/petals-bg.htm """ If you get the answer right on six successive rolls, I'll take that as prima facie evidence that you understand the game. """ The solution is that each number has a coefficient and the result is the sum of these coefficients: 1 = 0 2 = 0 3 = 2 4 = 0 5 = 4 6 = 0 Which is the number of points around the mid dot (the rose). This is the 3 face which has 2 dots around the mid dot: * * * And this is the 5 face with 2 dots around the mid dot * * * * * The rest has 0 dots around the mid dot (since they don't have a mid point). This rule is quite hard to find since it's the value that are significant, not the variables. The valid rule would be something like (A==3 + B == 3 + C == 3 + D == 3 + E == 3) + (A==5 + B == 5 + C == 5 + D == 5 + E == 5) This is tested with init_fun: init_fun=$(2*( ('A'==3) + ('B'==3) + ('C'==3) + ('D'==3) + ('E'==3)) + 4*(('A'==5) + ('B'==5) + ('C'==5) + ('D'==5) + ('E'==5))), which give a solution with 0 errors. Note the parenthesis around each equivalence which are needed. Here I try to recover this function. Here are som experiments. * Ops = [+,*,==], stop_criteria=generations, num_gens=1800 constants [2,3,4,5] gen = 29 (time: 3.512s) results_best = [[6,3 * (D == A) + (4 + (D == A))]] It's to hard to recover this specific function. * [+,-,*,/,if_then_else,==,!=] stop_criteria=generations, num_gens=1800 constants [2,3,4,5] gen = 1664 (time: 150.651s) results_best = [[4,if_then_else(D == 4,B,4) * (2 - (A != D))]] * [+,-,*,/,if_then_else,==,!=] no limit, constants 0..10 If finds the following solution (in 45 minutes), but it only works for this specific instance: [program = if_then_else(B - A,(0 / C + D) * 8 * ((B != 2) / A),if_then_else(E != D,4,E)),res = 4,count = 1] Cf petals_around_the_rose.conf */ import util. data(p4,Data,Vars,Unknown,Ops,Constants,MaxSize,Params) :- Data = [ [[A,B,C,D,E],X] : [A,B,C,D,E,X] in chunks_of([ 6,1,5,2,1,4, 5,4,4,4,4,4, 1,2,6,4,6,0, 3,4,5,3,2,8, % Here I got the correct hypothesis and just tested it 5,6,2,5,6,8, 6,3,6,2,2,2, 4,2,6,6,5,4, 1,3,2,3,6,4, 5,6,6,5,2,8, 6,3,6,3,1,4, 4,1,6,2,5,4 ],6)], Unknown = [6,1,5,2,1], Vars = ['A','B','C','D','E'], Ops = [+,-,*,/,if_then_else,==,!=], % Ops = [+,*,==], % Constants = [2,3,4,5], Constants = 0..10, MaxSize = 151, Params = new_map([ % init_fun=$(2*( ('A'==3) + ('B'==3) + ('C'==3) + ('D'==3) + ('E'==3)) + 4*(('A'==5) + ('B'==5) + ('C'==5) + ('D'==5) + ('E'==5))), init_size=1000, show_best=10, num_gens=1800, show_only_improvements=true, % stop_criteria=generations, % debug=true, remove_dups=true ]).