/* Ten sentences in Picat. From Adrian Groza "Modelling Puzzles in First Order Logic" """ Puzzle 142. Ten sentences In a list of 10 statements, the nth statement says there are exactly n false items in the list. Which of the statements, if any, are false? 1. In this list, exactly 1 statement is false. 2. In this list, exactly 2 statements are false. 3. In this list, exactly 3 statements are false. 4. In this list, exactly 4 statements are false. 5. In this list, exactly 5 statements are false. 6. In this list, exactly 6 statements are false. 7. In this list, exactly 7 statements are false. 8. In this list, exactly 8 statements are false. 9. In this list, exactly 9 statements are false. 10. In this list, exactly 10 statements are false. """ The unique solution is that the following sentence is true: 9. In this list, exactly 9 statements are false. This program was created by Hakan Kjellerstrand, hakank@gmail.com See also my Picat page: http://www.hakank.org/picat/ */ import cp. main => go. go => N = 10, X = new_list(N), X :: 0..1, foreach(I in 1..N) X[I] #<=> sum([X[J] #= 0 : J in 1..N] ) #= I end, solve(X), println(X), fail, nl.