I'm trying to solve the Einstein riddle using Prolog. When I'm trying to run by houses(Hs), it shows No. Task is
- The Brit lives in the red house.
- The Swede keeps dogs as pets.
- The Dane drinks tea.
- The green house is on the immediate left of the white house.
- The green house's owner drinks coffee.
- The owner who smokes Pall Mall rears birds.
- The owner of the yellow house smokes Dunhill.
- The owner living in the center house drinks milk.
- The Norwegian lives in the first house.
- The owner who smokes Blends lives next to the one who keeps cats.
- The owner who keeps the horse lives next to the one who smokes Dunhill.
- The owner who smokes Bluemasters drinks beer.
- The German smokes Prince.
- The Norwegian lives next to the blue house.
- The owner who smokes Blends lives next to the one who drinks water.
houses(Hs) :-
length(Hs, 5),
member(h(english,_,_,_,red), Hs),
member(h(swede,dog,_,_,_), Hs),
member(h(_,_,_,coffee,green), Hs),
member(h(dane,_,_,tea,_), Hs),
next(h(_,_,_,_,green), h(_,_,_,_,white), Hs),
member(h(_,bird,'Pall Mall',_,_), Hs),
member(h(_,_,'Dunhill',_,yellow), Hs),
Hs = [_,_,h(_,_,_,milk,_),_,_],
Hs = [h(norwegian,_,_,_,_)|_],
next(h(_,horse,_,_,_), h(_,_,'Dunhill',_,_), Hs),
next(h(_,_,blend,_,_), h(_,cat,_,_,_), Hs),
member(h(_,_,'Blue Master',beer,_), Hs),
member(h(german,_,'Prince',_,_), Hs),
next(h(norwegian,_,_,_,_), h(_,_,_,_,blue), Hs),
next(h(_,_,'Blend',_,_), h(_,_,_,water,_), Hs),
member(h(_,fish,_,_,_), Hs).
next(A, B, Ls) :- append(_, [A,B|_], Ls).
next(A, B, Ls) :- append(_, [B,A|_], Ls).
I have no idea what is wrong. Thanks