/* Dice with a difference, Enigma 290 in Picat. https://enigmaticcode.wordpress.com/2015/06/26/enigma-290-dice-with-a-difference/ """ From New Scientist #1438, 10th January 1985 [link] Throwing two dice will give you a number from 2 to 12. Of course, some numbers are more likely that others. The probability of 2 for instance is 1/36; of 3 is 2/36; of 4 is 3/36; …; of 7 is 6/36; …; of 8 is 5/36; …; of 12 is 1/36. That is true of two ordinary 6-sided dice, each bearing the letters of ENIGMA (which stand for the numbers one to six). It is also true of this special pair of dice I have made — one with 9 sides bearing the letters IMAGINING, the other with 4 sides bearing the letters of GAGS. (S is a positive integer). I’m not going to tell you how I constructed 9-sided and 4-sided dice. But I did, and they are fair dice. Can you interpret the MEANINGS of these fascinating facts? """ 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 => NN = 9, % first die, 9 sides, IMAGINING FF = 4, % second die, 4 sides, GAGS EE = 6, % ENIGMA dice, 6 sides K = 12, Probs = [1,2,3,4,5,6,5,4,3,2,1], % decision variables I :: 1..K, M :: 1..K, A :: 1..K, G :: 1..K, N :: 1..K, S :: 1..K, E :: 1..K, Dice9 = [I,M,A,G,I,N,I,N,G], Dice4 = [G,A,G,S], Dice6 = [E,N,I,G,M,A], foreach(P in 2..K) Probs[P-1] #= sum([ Dice9[II]+Dice4[JJ] #= P : II in 1..NN, JJ in 1..FF]), Probs[P-1] #= sum([ Dice6[II]+Dice6[JJ] #= P : II in 1..EE, JJ in 1..EE]) end, Vars = Dice9 ++ Dice4 ++ Dice6, solve([degree,split], Vars), println(dice9=Dice9), println(dice4=Dice4), println(dice6=Dice6), println(meanings=[M,E,A,N,I,N,G,S]), nl.