Skip to content

Commit d490eb4

Browse files
author
Georgi Shopov
committed
Change exercise 6.6 solution to use no self-derived facts
This solution uses just the facts given in the problem statement and no self-derived facts.
1 parent c3aa905 commit d490eb4

File tree

1 file changed

+7
-15
lines changed

1 file changed

+7
-15
lines changed

chapter-6/exercises.pl

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -160,18 +160,10 @@
160160
suffix(S,L) :- append(_,S,L).
161161
sublist(SubL,L) :- suffix(S,L), prefix(SubL,S).
162162

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

Comments
 (0)