Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
51
Task/Twelve-statements/Picat/twelve-statements.picat
Normal file
51
Task/Twelve-statements/Picat/twelve-statements.picat
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
% {{trans|Prolog}}
|
||||
go ?=>
|
||||
puzzle,
|
||||
fail, % check for more answers
|
||||
nl.
|
||||
go => true.
|
||||
|
||||
puzzle =>
|
||||
% 1. This is a numbered list of twelve statements.
|
||||
L = [A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12],
|
||||
L :: 0..1,
|
||||
element(1, L, 1),
|
||||
|
||||
% 2. Exactly 3 of the last 6 statements are true.
|
||||
A2 #<=> sum(L[7..12]) #= 3,
|
||||
|
||||
% 3. Exactly 2 of the even-numbered statements are true.
|
||||
A3 #<=> sum([L[I]:I in 1..12,I mod 2 == 0]) #= 2,
|
||||
|
||||
% 4. If statement 5 is true, then statements 6 and 7 are both true.
|
||||
A4 #<=> (A5 #=> (A6 #/\ A7)),
|
||||
|
||||
% 5. The 3 preceding statements are all false.
|
||||
A5 #<=> sum(L[2..4]) #= 0,
|
||||
|
||||
% 6. Exactly 4 of the odd-numbered statements are true.
|
||||
A6 #<=> sum([L[I]:I in 1..12,I mod 2 == 1]) #= 4,
|
||||
|
||||
% 7. Either statement 2 or 3 is true, but not both.
|
||||
A7 #<=> (A2 + A3 #= 1),
|
||||
|
||||
% 8. If statement 7 is true, then 5 and 6 are both true.
|
||||
A8 #<=> (A7 #=> A5 #/\ A6),
|
||||
|
||||
% 9. Exactly 3 of the first 6 statements are true.
|
||||
A9 #<=> sum(L[1..6]) #= 3,
|
||||
|
||||
% 10. The next two statements are both true.
|
||||
A10 #<=> (A11 #/\ A12),
|
||||
|
||||
% 11. Exactly 1 of statements 7, 8 and 9 are true.
|
||||
A11 #<=> (A7 + A8 + A9 #= 1),
|
||||
|
||||
% 12. Exactly 4 of the preceding statements are true.
|
||||
A12 #<=> sum(L[1..11]) #= 4,
|
||||
|
||||
solve(L),
|
||||
|
||||
println('L'=L),
|
||||
printf("Statements %w are true.\n", [I.to_string : I in 1..12, L[I] == 1].join(" ")),
|
||||
nl.
|
||||
Loading…
Add table
Add a link
Reference in a new issue