/* Ten statements problem in Picat. From Richard Wiseman http://richardwiseman.wordpress.com/2012/07/20/its-the-friday-puzzle-169/ """ Here are 10 numbered statements. How many of them are true? 1) Exactly one of these statements is true. 2) Exactly two of these statements are true. 3) Exactly three of these statements are true. 4) Exactly four of these statements are true. 5) Exactly five of these statements are true. 6) Exactly six of these statements are true. 7) Exactly seven of these statements are true. 8) Exactly eight of these statements are true. 9) Exactly nine of these statements are true. 10) Exactly ten of these statements are true. """ at_least_one = false [0,0,0,0,0,0,0,0,0,0] = 0 [1,0,0,0,0,0,0,0,0,0] = 1 at_least_one = true [1,0,0,0,0,0,0,0,0,0] = 1 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, member(AtLeastOne,[false,true]), println(at_least_one=AtLeastOne), X = new_list(N), X :: 0..1, foreach(I in 1..N) X[I] #= 1 #<=> sum(X) #= I end, Z #= sum(X), % if we can assume that at least one statement must be true: if AtLeastOne then Z #> 0 end, solve(X), println(X=Z), fail, nl.