Newsgroups: comp.lang.prolog
Path: cantaloupe.srv.cs.cmu.edu!das-news2.harvard.edu!news2.near.net!news3.near.net!noc.near.net!paperboy.wellfleet.com!news-feed-1.peachnet.edu!gatech!howland.reston.ans.net!Germany.EU.net!Munich.Germany.EU.net!ecrc!news
From: micha@ecrc.de (Micha Meier)
Subject: Re: Logiquiz solver
Message-ID: <D5xtGE.Arn@ecrc.de>
Sender: news@ecrc.de
Reply-To: micha@ecrc.de
Organization: European Computer-Industry Research Centre
References: <3406@nikhefh.nikhef.nl>
Date: Fri, 24 Mar 1995 09:09:47 GMT
Lines: 46

In article 3406@nikhefh.nikhef.nl, i14@nikhef.nl (Martin Los) writes:
> Hi,
> 
> I would like to implement a 'logiquiz' solver in prolog.

This is also often called 'zebra' puzzle. The easiest way to express
such problems is using CLP(FD) (constraint logic programming over
finite domains). For example, in ECLiPSe I would write

> Data: There are two boys : John and Mark
>       There are two girls : Marsha and Ginny
>       There are two places : cinema and dancing
>  
> Question : who goes with who and where if :
> Clues :
>       1. Marsha doesn't go to the cinema
>       2. Ginny does not go with John


[eclipse 3]: [John, Mark, Marsha, Ginny, Cinema, Dancing] :: 1..2,
	John ## Mark,
	Marsha ## Ginny,
	Cinema ## Dancing,
	Marsha ## Cinema,
	Ginny ## John,
	labeling([John, Mark, Marsha, Ginny, Cinema, Dancing]).

John = 1
Mark = 2
Marsha = 1
Ginny = 2
Cinema = 2
Dancing = 1     More? (;) 

In the ECLiPSe Extensions Manual (http://www.ecrc.de/eclipse/html/extroot/node51.html)
you can find an example how to code the original zebra puzzle from Lewis Carrol.

--Micha

---
Micha Meier			------------------------------------------------
ECRC, Arabellastr. 17		The opinions expressed above are private
D-81925 Munich 81		and may not reflect those of my employer.
micha@ecrc.de, Tel. +49-89-92699-108, Fax  +49-89-92699-170


