I'm trying to solve the Einstein Riddle using Prolog. I'm sorry for my English. The task is:
- In the block of flats is 5 flats. (ground floor a 1., 2., 3., 4. floor)
- Family Mullerovi have 4 children.
- An administrator lives on the middle floor.
- Mrs. Meierova pays for her flat 60 crowns less than a doctor on 3. floor.
- Family living on the hightest floor have 5 children.
- Family Kernovi have 1 child than teacher.
- Mr Kaufmann works as a sales representative.
- The teacher pays for her flat 1740 crowns.
- On the hightest floor janitor lives.
- The doctor pays for his flat 1800 crowns.
- In the flat, which costs 1760 crowns, arent any children.
- On the 2.floor the family have twice more children than family on the 3.floor.
- Mr Hanz lives directly above family Kernovi.
- In the flat under the janitor live 2 children.
- Mullerovi pay for their flat 1770 crowns.
- The roof flat is cheaper 10 crowns than then ground floor.
- Sales representative pays 30 crowns more than janitor does.
My code looks like, I don't know how to solve problems with hire:
person('Name', 'Job','Children','Hire','Floor').
houses(Hs):-
length(Hs),
member(person(mullerovi,_,4,1770,_),Hs),
member(person(_,administrator,_,_,2),Hs),
member(person(_,doctor,_,1800,_),Hs),
pays_less(person(_,doctor,_,Hire,_),person('Meinova',_,_,Hire-60,_),Hs),
member(person(_,_,5,_,4),Hs),
have_one_children_less(person('Kernovi',_,Children-1,_,_),person(_,teacher,Children,_,_),Hs),
member(person('Kaufmann','Sales representative',_,_,_),Hs),
member(person(_,teacher,_,1740,_),Hs),
member(person(_,janitor,_,_,4),Hs),
member(person(_,_,0,1760,_),Hs),
have_2x_children(
person(_,_,2*Children,_,2),
person(_,_,Children,_,3),Hs),
lives_above(person('Hanz',_,_,_,_),person('Kernovi',_,_,_,_),Hs),
lives_above(person(_,janitor,_,_,_),person(_,_,2,_,_),Hs),
pays_more(
person(_,_,_,Hire+10,4),
person(_,_,_,Hire,'Ground floor'),Hs),
pays_more(
person(_,'Sale representative',_,Hire+30,_),
person(_,janitor,_,Hire,_),Hs).
Thanks for any advices.