Toggle navigation
?
users online
Logout
Open hangout
Open chat for current file
male(george). male(john). male(robert). female(barbara). female(christine). female(yolanda). person(X) :- male(X). person(X) :- female(X). room(kitchen). room(bathroom). room(diningroom). room(livingroom). room(pantry). room(study). weapon(bag). weapon(firearm). weapon(gas). weapon(knife). weapon(poison). weapon(rope). unique(A,B,C,D,E,F) :- A \= B, A \= C, A \= D, A \= E, A \= F, B \= C, B \= D, B \= E, B \= F, C \= D, C \= E, C \= F, D \= E, D \= F, E \= F. suspects(suspect(george,WA,RA), suspect(john,WB,RB), suspect(robert,WC,RC), suspect(barbara,WD,RD), suspect(christine,WE,RE), suspect(yolanda,WF,RF)) :- weapon(WA), weapon(WB), weapon(WC), weapon(WD), weapon(WE), weapon(WF), unique(WA,WB,WC,WD,WE,WF), room(RA), room(RB), room(RC), room(RD), room(RE), room(RF), unique(RA,RB,RC,RD,RE,RF). /* The man in the kitchen was not found with the rope, knife, or bag. Which weapon, then, which was not the firearm, was found in the kitchen?*/ clue1(Suspects) :- member(suspect(Person,Weapon,kitchen),Suspects), male(Person), weapon(Weapon), Weapon \= rope, Weapon \= knife, Weapon \= bag, Weapon \= firearm. /* Clue 2: Barbara was either in the study or the bathroom; Yolanda was in the other. Which room was Barbara found in? */ clue2(Suspects) :- member(suspect(barbara, _, study),Suspects), member(suspect(yolanda, _,bathroom),Suspects). clue2(Suspects) :- member(suspect(yolanda, _, study),Suspects), member(suspect(barbara, _,bathroom),Suspects). /* Clue 3: The person with the bag, who was not Barbara nor George, was not in the bathroom nor the dining room. Who had the bag in the room with them? */ clue3(Suspects) :- member(suspect(Person,bag,Room),Suspects), Person \= barbara, Person \= george, Room \= bathroom, Room \= diningroom. /* Clue 4: The woman with the rope was found in the study. Who had the rope? */ clue4(Suspects) :- member(suspect(Person,rope,study),Suspects), female(Person). /* Clue 5: The weapon in the living room was found with either John or George. What weapon was in the living room? */ clue5(Suspects) :- member(suspect(john,_,livingroom),Suspects). clue5(Suspects) :- member(suspect(george,_,livingroom),Suspects). /* Clue 6: The knife was not in the dining room. So where was the knife? */ clue6(Suspects) :- member(suspect(_,knife,Room),Suspects), Room \= diningroom. /* Clue 7: Yolanda was not with the weapon found in the study nor the pantry. What weapon was found with Yolanda? */ clue7(Suspects) :- member(suspect(yolanda,_,Room),Suspects), Room \= study, Room \= pantry. /* Clue 8: The firearm was in the room with George. In which room was the firearm found? */ clue8(Suspects) :- member(suspect(george,firearm,_),Suspects). /* It was discovered that Mr. Boddy was gassed in the pantry. The suspect found in that room was the murderer. Who, then, do you point the finger towards? */ killer(X, Suspects) :- member(suspect(X,gas,pantry),Suspects). resolved(X) :- suspects(A,B,C,D,E,F), Suspects = [A,B,C,D,E,F], clue1(Suspects), clue2(Suspects), clue3(Suspects), clue4(Suspects), clue5(Suspects), clue6(Suspects), clue7(Suspects), clue8(Suspects), killer(X, Suspects).