Last active
April 23, 2020 19:59
-
-
Save franckverrot/769014df59c947b2ce9543c5ba4a1064 to your computer and use it in GitHub Desktop.
MiniZinc version of the lock problem
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var 0..9: POS_1; | |
var 0..9: POS_2; | |
var 0..9: POS_3; | |
constraint ( | |
% 682 one correct and well placed | |
( | |
(POS_1 == 6 /\ (not (POS_2 in {8, 2})) /\ (not (POS_3 in {8, 2}))) | |
\/ (POS_2 == 8 /\ (not (POS_1 in {6, 2})) /\ (not (POS_3 in {6, 2}))) | |
\/ (POS_3 == 2 /\ (not (POS_1 in {6, 8})) /\ (not (POS_2 in {6, 8}))) | |
) | |
% 614 one correct not well placed | |
/\ ( | |
(POS_1 == 1 /\ (not (POS_2 in {6, 4})) /\ (not (POS_3 in {6, 4}))) | |
\/ (POS_1 == 4 /\ (not (POS_2 in {6, 1})) /\ (not (POS_3 in {6, 1}))) | |
\/ (POS_2 == 6 /\ (not (POS_1 in {1, 4})) /\ (not (POS_3 in {1, 4}))) | |
\/ (POS_2 == 4 /\ (not (POS_1 in {6, 1})) /\ (not (POS_3 in {6, 1}))) | |
\/ (POS_3 == 6 /\ (not (POS_2 in {1, 4})) /\ (not (POS_1 in {1, 4}))) | |
\/ (POS_3 == 1 /\ (not (POS_2 in {6, 4})) /\ (not (POS_1 in {6, 4}))) | |
) | |
% Disambiguate the rule so 6 can't be repeated | |
/\ (POS_1 != POS_2 /\ POS_2 != POS_3) | |
% 206 two correct both not well placed | |
/\ ( | |
(POS_1 == 0 /\ POS_2 == 2 /\ POS_3 != 6) | |
\/ (POS_1 == 0 /\ POS_2 == 6 /\ POS_3 != 2) | |
\/ (POS_1 == 6 /\ POS_2 == 2 /\ POS_3 != 0) | |
\/ (POS_2 == 2 /\ POS_3 == 0 /\ POS_1 != 6) | |
\/ (POS_2 == 6 /\ POS_3 == 2 /\ POS_1 != 0) | |
\/ (POS_2 == 6 /\ POS_3 == 0 /\ POS_1 != 2) | |
\/ (POS_3 == 2 /\ POS_1 == 0 /\ POS_2 != 6) | |
\/ (POS_3 == 2 /\ POS_1 == 6 /\ POS_2 != 0) | |
\/ (POS_3 == 0 /\ POS_1 == 6 /\ POS_2 != 2) | |
) | |
% 738 nothing is correct | |
/\ ( | |
((not (POS_1 in {7, 3, 8})) /\ (not (POS_2 in {7, 3, 8})) /\ (not (POS_3 in {7, 3, 8}))) | |
) | |
% 380 one number correct not well placed | |
/\ ( | |
(POS_1 == 8 /\ (not (POS_2 in {3, 0})) /\ (not (POS_3 in {3, 0}))) | |
\/ (POS_1 == 0 /\ (not (POS_2 in {3, 8})) /\ (not (POS_3 in {3, 8}))) | |
\/ (POS_2 == 3 /\ (not (POS_1 in {8, 0})) /\ (not (POS_3 in {8, 0}))) | |
\/ (POS_2 == 0 /\ (not (POS_1 in {3, 8})) /\ (not (POS_3 in {3, 8}))) | |
\/ (POS_3 == 3 /\ (not (POS_2 in {8, 0})) /\ (not (POS_1 in {8, 0}))) | |
\/ (POS_3 == 8 /\ (not (POS_2 in {3, 0})) /\ (not (POS_1 in {3, 0}))) | |
) | |
); | |
solve satisfy; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment