/* Eliza Pseudonym of Puzzlania 7 in Picat. % From % A Cleverly-Titled Logic Puzzle Blog (or Or, A Logically-Titled Clever Puzzle Blog) % http://mathgrant.blogspot.com/2008/10/puzzle-94-eliza-pseudonym-of-puzzlania.html % % """ % During a six-day period from Monday through Saturday, Eliza Pseudonym and % her friends Anna, Barbra, Carla, Delilah, and Fiona have subscribed to an % internet mailing list that features a new word every day. No two women % subscribed on the same day. On each day during the six-day period, a % different word has been featured (abulia, betise, caryatid, dehisce, % euhemerism, and floruit, in some order). From the clues below, determine % the day on which each woman subscribed, and the day on which each word % was featured. % % 1. Exactly one of the women has a name beginning with the same letter of % the alphabet as the word featured on the day that she subscribed to the % mailing list. % 2. The word "caryatid" was featured precisely two days prior to Fiona % joining the mailing list. % 3. Carla joined the mailing list on Friday. % 4. Anna signed up for the mailing list precisely one day after the word % "euhemerism" was highlighted. % 5. Wednesday's word did not end with the letter "e". % 6. Barbra subscribed precisely three days after the word "dehisce" was % featured. % """ % % Solution: % friends : [3, 4, 5, 2, 1, 6] % all_words: [3, 6, 4, 1, 2, 5] % anna : 3 % barbra : 4 % carla : 5 % delilah: 2 % eliza : 1 % fiona : 6 % abulia : 3 % betise : 6 % caryatid : 4 % dehisce : 1 % euhemerism: 2 % floruit : 5 % I.e. % % Day Who Word % monday : eliza dehisce % tuesday : delilah euhemerism % wednesday: anna abulia % thursday : barbra caryatid % friday : carla floruit % saturday : fiona betise % 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 ?=> Days = [_Monday,_Tuesday,Wednesday,_Thursday,Friday,_Saturday], Days = 1..Days.len, DaysS = [monday,tuesday,wednesday,thursday,friday,saturday], Friends = [Anna, Barbra, Carla, Delilah, Eliza, Fiona], Friends :: Days, FriendsS = [anna, barbra, carla, delilah, eliza, fiona], AllWords = [Abulia,Betise, Caryatid,Dehisce,Euhemerism,Floruit], AllWords :: Days, AllWordsS = [abulia,betise, caryatid,dehisce,euhemerism,floruit], SumBeginnings #= (Anna #= Abulia) + (Barbra #= Betise) + (Caryatid #= Carla) + (Dehisce #= Delilah) + (Eliza #= Euhemerism) + (Fiona #= Floruit), SumBeginnings :: Days, all_different(Friends), all_different(AllWords), % 1. Exactly one of the women has a name beginning with the same letter of % the alphabet as the word featured on the day that she subscribed to the % mailing list. 1 #= SumBeginnings, % 2. The word "caryatid" was featured precisely two days prior to Fiona % joining the mailing list. Caryatid #= Fiona - 2, % 3. Carla joined the mailing list on Friday. Carla #= Friday, % 4. Anna signed up for the mailing list precisely one day after the word % "euhemerism" was highlighted. Anna #= Euhemerism + 1, % 5. Wednesday's word did not end with the letter "e". ( Wednesday #= Abulia #\/ Wednesday #= Caryatid #\/ Wednesday #= Euhemerism #\/ Wednesday #= Floruit ), % 6. Barbra subscribed precisely three days after the word "dehisce" was % featured. Barbra #= Dehisce + 3, Vars = Friends ++ AllWords, solve(Vars), % println(friends=Friends), % println(allWords=AllWords), % println(friends=[FriendsS[Friends[I]] : I in Days]), % println(allWords=[AllWordsS[AllWords[I]] : I in Days]), foreach(D in Days) nth(F,Friends,D), nth(W,AllWords,D), println([DaysS[D],FriendsS[F],AllWordsS[W]]) end, nl, fail, nl. go => true.