|
160 | 160 | suffix(S,L) :- append(_,S,L).
|
161 | 161 | sublist(SubL,L) :- suffix(S,L), prefix(SubL,S).
|
162 | 162 |
|
163 |
| -house(blue,japanese,Xc). |
164 |
| -house(red,english,snail). |
165 |
| -house(Za,spanish,jaguar). |
166 |
| - |
167 |
| -street(house(LCol,LNat,LPet), |
168 |
| - house(MCol,MNat,MPet), |
169 |
| - house(RCol,RNat,RPet)) :- |
170 |
| - sublist([LCol,MCol,RCol],[green,red,blue]), |
171 |
| - sublist([LNat,MNat,RNat],[japanese,english,spanish]), |
172 |
| - sublist([LPet,MPet,RPet],[zebra,snail,jaguar]). |
173 |
| - |
174 |
| -%% Not quite as beautiful as I had hoped, since I had to derive the whole |
175 |
| -%% english is snailkeeper and japanese living the blue house rather than |
176 |
| -%% specifying it as is. Also the riddle seems to be too simple compared to the |
177 |
| -%% "original" Einstein's Puzzle. |
| 163 | +zebra_owner(ZebraOwner) :- |
| 164 | + Street = [_, _, _], |
| 165 | + member(house(red, englishman, _), Street), |
| 166 | + member(house(_, spanish, jaguar), Street), |
| 167 | + member(house(_, ZebraOwner, zebra), Street), |
| 168 | + sublist([house(_, _, snail), house(_, japanese, _)], Street), |
| 169 | + sublist([house(_, _, snail), house(blue, _, _)], Street). |
0 commit comments