/* From http://puzzlor.editme.com/Cookiebakeoff """ Historically, baking has been considered an art rather than a science. As a contestant in a cookie bake-off, your attempts to create the perfect cookie have failed. For your final attempt, you decide to use your analytical skills to analyze your past attempts to see if you can find the recipe for the perfect cookie. Table 1 shows your past 15 attempted recipes, each with varying amounts of Sugar, Flour, and Butter, and a corresponding judge’s score for each recipe. The judge’s scores range from 0 (worst) to 100 (best). None of your recipes so far have achieved the coveted perfect score of 100. All recipes sum up to 8 cups total of the three ingredients. Batch Sugar Flour Butter Score 1 3 4 1 70 2 1 4 3 95 3 2 2 4 45 4 2 1 5 20 5 2 3 3 85 6 3 2 3 55 7 2 5 1 80 8 1 1 6 15 9 1 5 2 90 10 3 3 2 75 11 4 2 2 40 12 1 3 4 65 13 1 6 1 60 14 4 1 3 25 15 4 3 1 50 Table 1 Question: Given your past recipes and scores, which recipe below has the best chance of achieving a perfect score of 100? a.) 1 cup sugar; 2 cups flour; 5 cups butter b.) 2 cups sugar; 4 cups flour; 2 cup butter c.) 3 cups sugar; 1 cup flour; 4 cups butter Send your answer to puzzlor@gmail.com by February 15th, 2013. """ * stop_criteria=generations 1800 generations gen = 185 (time: 4.289s) results_best = [[141.413793103448256,(Flour * -3 - -33) * (Flour - 5 / 29)]] gen = 421 (time: 10.096s) results_best = [[134.437942799192456,sqrt(Sugar + Butter) * 5 * Flour * (47 / pow2(5))]] Cf cookie_bake_off.pi Also: cookie_bake_off.pi and cookie_bake_off2.pi */ import util. data(cookie_bake_of,Data,Vars,Unknown,Ops,Constants,MaxSize,Params) :- Data = [ [[A,B,C],D] : [A,B,C,D] in chunks_of([ % Sugar Flour Butter Score 3,4,1,70, 1,4,3,95, 2,2,4,45, 2,1,5,20, 2,3,3,85, 3,2,3,55, 2,5,1,80, 1,1,6,15, 1,5,2,90, 3,3,2,75, 4,2,2,40, 1,3,4,65, 1,6,1,60, 4,1,3,25, 4,3,1,50 % 1,2,5,? % 2,4,2,? % 3,1,4,? ],4)], % Ops = [+,/,-,*,round], Ops = [+,/,-,*,pow2,pow_mod2,sqrt], Constants = [random(-100,100) : _ in 1..10], Vars = ['Sugar','Flour','Butter'], Unknown = [1,2,5], % Unknown = [2,4,2], % Unknown = [3,1,4], MaxSize = 51, Params = new_map([ approx=1, total_approx=4, init_size=500, show_best=1, num_gens=1800, stop_criteria=generations ]). % Params = new_map().