/* Congress puzzle in Picat. From the Mosel example problem k3congress_ka.mos """ Congress puzzle At an international congress taking place on 7-11 August five researchers of different nationality are giving talks, each on a different day. Find out the date and nationality for every researcher from the following information: a) Michael is not Japanese. b) Eric is French and he talks before the 10th. c) Arabinda talks on the 9th. d) The Chinese who is not Hitoshi gives his talk on the 8th, before Michael. e) Hitoshi does his talk after the Indian and before the American. (c) 2005 Dash Associates author: S. Heipcke, March 2005 """ This Picat model was created by Hakan Kjellerstrand, hakank@gmail.com See also my Picat page: http://www.hakank.org/picat/ */ import cp. main => go. go ?=> N = 5, DAYS = 7..11, Names = [Arabinda,Eric,Hitoshi,Michael,Zhicheng], Names = 1..Names.len, NAMES = ["Arabinda","Eric","Hitoshi","Michael","Zhicheng"], Nat = [Japanese,French,Chinese,American,Indian], Nat = 1..Nat.len, NAT = ["Japanese","French","Chinese","American","Indian"], % decision variables % Choice of day for person p TalkP = new_list(N), TalkP :: DAYS, % Choice of day for nationality n TalkN = new_list(N), TalkN :: DAYS, % Every researcher on a different day all_different(TalkP), % Every nationality exactly once all_different(TalkN), % a: Michael is not Japanese TalkP[Michael] #!= TalkN[Japanese], % b: Eric is French and he talks before the 10th TalkP[Eric] #= TalkN[French], TalkP[Eric] #<= 9, % c: Arabinda talks on the 9th TalkP[Arabinda] #= 9, % d: The Chinese who is not Hitoshi gives his talk on the 8th, before Michael TalkP[Hitoshi] #!= TalkN[Chinese], TalkN[Chinese] #= 8, TalkP[Michael] #>= 9, % e: Hitoshi does his talk after the Indian and before the American TalkP[Hitoshi] #>= TalkN[Indian] + 1, TalkP[Hitoshi] #<= TalkN[American] - 1, Vars = TalkP ++ TalkN, solve(Vars), println(talkP=TalkP), println(talkN=TalkN), nl, println("The Schedule:"), foreach(D in DAYS) nth(PP,TalkP,D), nth(NN,TalkN,D), println([day=D,NAMES[PP],NAT[NN]]) end, nl, fail, nl. go => true.