/* Funny Dice in Picat. http://ccgi.gladman.plus.com/wp/?page_id=2671 """ Sunday Times Teaser 2739 – Funny Dice by Michael Fletcher I have two non-standard cubic dice, one red and one blue, each with positive whole numbers on each face. The total of the six numbers on the red die is higher than the same total for the blue die. When I repeatedly throw them and add their two values the results, in least to most likely order, are: 2/12, 3/11, 4/10, 5/9, 6/8 and 7. What are the numbers on the red dice? """ This Picat model was created by Hakan Kjellerstrand, hakank@gmail.com See also my Picat page: http://www.hakank.org/picat/ */ import cp. main => go. go => N = 6, % decision variables Red = new_list(N), Red :: 1..12, Blue = new_list(N), Blue :: 1..12, Probs = new_list(11), Probs :: 1..12, % domains foreach(I in 1..N) Red[I] #>= 1, Blue[I] #>= 1 end, % The total of the six numbers on the red die is higher than the same total for the blue die. sum(Red) #> sum(Blue), % ensure the probabilities foreach(P in 2..12) Probs[P-1] #>= 1, % domains Probs[P-1] #= sum([ Red[I]+Blue[J] #= P : I in 1..N, J in 1..N]) end, % the relations of the probabilities foreach(I in 2..6) Probs[I-1] #= Probs[12-I+2-1], Probs[I-1] #< Probs[I+1-1], Probs[6+I-1-1] #> Probs[6+I-1] end, Probs[7-1] #= max(Probs), % symmetry breaking (without it, it takes longer time) increasing(Red), increasing(Blue), Vars = Probs ++ Blue ++ Red, solve([min,split],Vars), println(probs=Probs), println(red=Red), println(blue=Blue), nl. increasing(List) => foreach(I in 2..List.len) List[I-1] #=< List[I] end.