So I tried solving another Einstein Puzzle by using tutorial that I learned myself from this site. But, I dont seem to get the answer. When I make the query,it only returns true when I want to know which couple likes Violet.
exist(A, (A,_,_,_,_,_,_,_)).
exist(A, (_,A,_,_,_,_,_,_)).
exist(A, (_,_,A,_,_,_,_,_)).
exist(A, (_,_,_,A,_,_,_,_)).
exist(A, (_,_,_,_,A,_,_,_)).
exist(A, (_,_,_,_,_,A,_,_)).
exist(A, (_,_,_,_,_,_,A,_)).
exist(A, (_,_,_,_,_,_,_,A)).
borrowed(B,C, (B,_,_,_,_,_,_,C)).
borrowed(B,C, (_,B,_,_,_,_,_,C)).
borrowed(B,C, (_,_,B,_,_,_,_,C)).
borrowed(B,C, (_,_,_,B,_,_,_,C)).
borrowed(B,C, (_,_,_,_,B,_,_,C)).
borrowed(B,C, (_,_,_,_,_,B,_,C)).
borrowed(B,C, (_,_,_,_,_,_,B,C)).
solution(LikeViolet) :- Couples = (couple(_H1,_W1,_S1,_E1,_C1,_CL1,_B1,_BR1), couple(_H2,_W2,_S2,_E2,_C2,_CL2,_B2,_BR2),
couple(_H3,_W3,_S3,_E3,_C3,_CL3,_B3,_BR3), couple(_H4,_W4,_S4,_E4,_C4,_CL4,_B4,_BR4),
couple(_H5,_W5,_S5,_E5,_C5,_CL5,_B5,_BR5), couple(_H6,_W6,_S6,_E6,_C6,_CL6,_B6,_BR6),
couple(_H7,_W7,_S7,_E7,_C7,_CL7,_B7,_BR7), couple(_H8,_W8,_S8,_E8,_C8,_CL8,_B8,_BR8)),
exist(couple(_,_Daniella,_Black,_ShopAsst,_,_,_,_),Couples),
exist(couple(_,_,_,_,_Fiat,_Red,_Seadog,_),Couples),
exist(couple(_Owen,_Victoria,_,_,_,_Brown,_,_),Couples),
exist(couple(_Stan,_Hannah,_Horricks,_,_,_White,_,_),Couples),
exist(couple(_,_Jenny,_Smith,_WarehouseManager,_Wartburg,_,_,_),Couples),
borrowed(couple(_Alexander,_Monica,_,_,_,_,_,_),couple(_,_,_,_,_,_,_,Grandfather),Couples),
exist(couple(_Mathew,_,_,_,_,_Pink,MulatkaGabriela,_),Couples),
exist(couple(_Oto,_Irene,_,_Accountants,_,_,_,_),Couples),
borrowed(couple(_,_,_,_,_Trabant,_,_,_),couple(_,_,_,_,_,_,_,_WeWereFive),Couples),
exist(couple(_,_,_Cermaks,_TixCollect,_,_,_ShedStoat,_),Couples),
borrowed( couple(_,_,_Kurils,_Doctors,_,_,_,_),couple(_,_,_,_,_,_,_,SlovackoJudge),Couples),
exist(couple(_Paul,_,_,_,_,_Green,_,_),Couples),
exist(couple(_,_Veronica,_Dvorak,_,_,_Blue,_,_),Couples),
exist(couple(_Rick,_,_,_,_Ziguli,_,SlovackoJudge,_),Couples),
borrowed( couple(_,_,_,_,_,_,_DameCamissar,_),couple(_,_,_,_,_,_,_,MulatkaGabriela),Couples),
exist(couple(_,_,_,_,_Dacia,Violet,_,_),Couples),
borrowed( couple(_,_,_,_Teachers,_,_,_,_),couple(_,_,_,_,_,_,_,_DameCommissar),Couples),
exist(couple(_,_,_,_Agriculturalist,_Moskvic,_,_,_),Couples),
exist(couple(_,Pamela,_,_,_Renault,_,Grandfather,_),Couples),
borrowed(couple(_,Pamela,_,_,_,_,_,_),couple(_,_,_Zajac,_,_,_,_,_),Couples),
borrowed(couple(_Robert,_,_,_,_,_Yellow,_,_),couple(_,_,_,_,_,_,_,ModernComedy),Couples),
exist(couple(_,_,_Swain,_Shoppers,_,_,_,_),Couples),
exist(couple(_,_,_,_,_Skoda,_,ModernComedy,_),Couples),
exist(couple(_,_,LikeViolet,_,_,Violet,_,_),Couples).
One of the problems in your code is that you're using variables where you should be using atoms to represent the bits of information that you have from the puzzle cues. For example, your have
exist(couple(_,_,_,_,_Skoda,_,ModernComedy,_),Couples)
instead ofexist(couple(_,_,_,_,_skoda,_,modern_comedy,_),Couples)
. Thus yourLikeViolet
variable in your query will never be instantiated with the answer you're looking for.