this repo has no description
1% RUNS ON mzn20_fd 2% RUNS ON mzn-fzn_fd 3% RUNS ON mzn20_mip 4 5% Regression test for a bug in mzn2fzn 1.2. The optimisation pass was leaving 6% dangling references to variables it had "eliminated". The symptom was the 7% following error from the FlatZinc interpreter: 8% 9% enigma_1568.fzn:28: 10% symbol error: `INT____3' undeclared 11% enigma_1568.fzn:30: 12% symbol error: `INT____3' undeclared 13% 14% (This model is from the original bug report.) 15 16% Enigma problem 1568 (Odd puzzle) in MiniZinc. 17% 18% From New Scientist 19% http://www.newscientist.com/article/mg20427311.100-enigma-number-1568.html 20% """ 21% 21 October 2009 by Albert Haddad 22% 23% Odd puzzle 24% 25% In this multiplication sum the digits have been replaced by letters and 26% dots. Different letters stand for different digits, the same letter 27% stands for the same digit, each dot can be any digit, and leading 28% digits cannot be zero. 29% 30% [ 31% . . . | num1 32% * . . . | num2 33% ------- 34% . . . | num3 35% . . . | num4 36% O D D | ODD 37% --------- 38% P U Z Z L E | PUZZLE 39% 40% ] 41% 42% What is the six-figure odd PUZZLE? 43% """ 44 45% 46% This MiniZinc model was created by Hakan Kjellerstrand, hakank@bonetmail.com 47% See also my MiniZinc page: http://www.hakank.org/minizinc 48% 49include "globals.mzn"; 50 51int: n = 7; % number of unknown 52set of int: Digits = 0..9; 53var Digits: O; 54var Digits: D; 55var Digits: P; 56var Digits: U; 57var Digits: Z; 58var Digits: L; 59var Digits: E; 60array[1..n] of var Digits: x; 61 62var 100..999: num1; 63var 100..999: num2; 64var 100..999: num3; 65var 100..999: num4; 66var 100..999: ODD ; 67var 100000..999999: PUZZLE; 68 69predicate cp1d(array[int] of var int: x, array[int] of var int: y) = 70 assert(index_set(x) = index_set(y), 71 "cp1d: x and y have different sizes", 72 forall(i in index_set(x)) ( x[i] = y[i] ) ) 73; 74 75 76% solve satisfy; 77solve :: int_search( 78 x ++ [num1,num2,num3,num4,ODD,PUZZLE], 79 first_fail, 80 indomain_min, 81 complete) 82 satisfy; 83 84constraint 85 cp1d(x, [O,D,P,U,Z,L,E]) /\ 86 87 all_different(x) /\ 88 89 ODD = 100*O + 10*D + D /\ 90 PUZZLE = 100000*P + 10000*U + 1000*Z + 100*Z + 10*L + E /\ 91 92 num1 * num2 = num3 + num4*10 + ODD*100 /\ 93 PUZZLE = num1 * num2 /\ 94 95 PUZZLE mod 2 = 1 /\ % PUZZLE is odd 96 97 % And then code the "long multiplication" 98 num1 * (num2 mod 10) = num3 /\ 99 num1 * ((num2 div 10) mod 10) = num4 /\ 100 num1 * (num2 div 100) = ODD 101; 102 103output [ 104 "O = ", show(O), ";\n", 105 "D = ", show(D), ";\n", 106 "P = ", show(P), ";\n", 107 "U = ", show(U), ";\n", 108 "Z = ", show(Z), ";\n", 109 "L = ", show(L), ";\n", 110 "E = ", show(E), ";\n", 111 "x = ", show(x), ";\n", 112 "num1 = ", show(num1), ";\n", 113 "num2 = ", show(num2), ";\n", 114 "num3 = ", show(num3), ";\n", 115 "num4 = ", show(num4), ";\n", 116 "ODD = ", show(ODD), ";\n", 117 "PUZZLE = ", show(PUZZLE), ";\n" 118];