Created
April 12, 2020 04:43
-
-
Save franckverrot/69d60c25cd17af9a6a82044008d4b3b9 to your computer and use it in GitHub Desktop.
Lock code
This file contains hidden or 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
solution(POS_1, POS_2, POS_3) :- | |
member(POS_1, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]), | |
member(POS_2, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]), | |
member(POS_3, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]), | |
/* 682 one correct and well placed */ | |
( POS_1 = 6; POS_2 = 8; POS_3 = 2), | |
/* 614 one correct not well placed */ | |
( | |
POS_1 = 1, \+ member(POS_2, [6, 4]), \+ member(POS_3,[6, 4]) | |
; POS_1 = 4, \+ member(POS_2, [6, 1]), \+ member(POS_3,[6, 1]) | |
; POS_2 = 6, \+ member(POS_1, [1, 4]), \+ member(POS_3,[1, 4]) | |
; POS_2 = 4, \+ member(POS_1, [6, 1]), \+ member(POS_3,[6, 1]) | |
; POS_3 = 6, \+ member(POS_2, [1, 4]), \+ member(POS_1,[1, 4]) | |
; POS_3 = 1, \+ member(POS_2, [6, 4]), \+ member(POS_1,[6, 4]) | |
), | |
/* 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 */ | |
\+ member(POS_1, [7, 3, 8]), \+ member(POS_2, [7, 3, 8]), \+ member(POS_3, [7, 3, 8]), | |
/* 380 one number correct not well placed */ | |
( | |
POS_1 = 8, \+ member(POS_2, [3, 0]), \+ member(POS_3, [3, 0]) | |
; POS_1 = 0, \+ member(POS_2, [3, 8]), \+ member(POS_3, [3, 8]) | |
; POS_2 = 3, \+ member(POS_1, [8, 0]), \+ member(POS_3, [8, 0]) | |
; POS_2 = 0, \+ member(POS_1, [3, 8]), \+ member(POS_3, [3, 8]) | |
; POS_3 = 3, \+ member(POS_2, [8, 0]), \+ member(POS_1, [8, 0]) | |
; POS_3 = 8, \+ member(POS_2, [3, 0]), \+ member(POS_1, [3, 0]) | |
). | |
main :- | |
forall( | |
solution(POS_1, POS_2, POS_3), | |
(write(POS_1), write(POS_2), write(POS_3), nl) | |
). |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
swipl -l lock.pl -t main
pour exécuter