/* Who is the mother puzzle in Picat. From https://www.reddit.com/r/puzzles/comments/1e9qct0/can_you_figure_out_who_the_mother_is/ """ Can you figure out who the mother is? Below are four statements pertaining to mother and her four daughters. 1. Ameni is the mother. 2. Dessa and Komi are both daughters. 3. Insi is the mother. 4. One of Ameni, Veya or Komi is the mother, One of the above statements is true, while the rest are false. Knowhing this information, can you figure out who the mother is? """ Solution: people = [2,2,2,1,2] s = [0,0,0,1] mother = [komi] 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 = 4, Mother = 1, Daughter = 2, People = [Ameni,Dessa,Insi,Komi,Veya], People :: Mother..Daughter, PeopleS = [ameni,dessa,insi,komi,veya], count(Mother,People) #= 1, S = new_list(N), S :: 0..1, sum(S) #= 1, % 1. Ameni is the mother. S[1] #<=> Ameni #= Mother, % 2. Dessa and Komi are both daughters. S[2] #<=> (Dessa #= Daughter #/\ Komi #= Daughter), % 3. Insi is the mother. S[3] #<=> Insi #= Mother, % 4. One of Ameni, Veya or Komi is the mother, S[4] #<=> (Ameni #= Mother #\/ Veya #= Mother #\/ Komi #= Mother), solve(People ++ S), println(people=People), println(s=S), println(mother=[PeopleS[I] : I in 1..N, People[I] == Mother]), nl, fail, nl. go => true.