Rocksolid Light

News from da outaworlds

mail  files  register  groups  login

Message-ID:  

BOFH excuse #99: SIMM crosstalk.


comp / comp.lang.lisp / Zebra puzzle

SubjectAuthor
* Zebra puzzleB. Pym
`- Re: Zebra puzzlesteve g

1
Subject: Zebra puzzle
From: B. Pym
Newsgroups: comp.lang.lisp
Organization: A noiseless patient Spider
Date: Tue, 6 Aug 2024 03:19 UTC
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Nobody447095@here-nor-there.org (B. Pym)
Newsgroups: comp.lang.lisp
Subject: Zebra puzzle
Date: Tue, 6 Aug 2024 03:19:32 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 84
Message-ID: <v8s4o0$1bp29$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Injection-Date: Tue, 06 Aug 2024 05:19:32 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="3b22668de36180485571eeb8efed0a5f";
logging-data="1434697"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/Drv14JboSE7YFIkMBVCk3"
User-Agent: XanaNews/1.18.1.6
Cancel-Lock: sha1:dXrMBu2mywXFEmCZTHURQuNpxyI=
View all headers

Rosetta: Zebra puzzle

> There are five houses.
> The English man lives in the red house.
> The Swede has a dog.
> The Dane drinks tea.
> The green house is immediately to the left of the white house.
> They drink coffee in the green house.
> The man who smokes Pall Mall has birds.
> In the yellow house they smoke Dunhill.
> In the middle house they drink milk.
> The Norwegian lives in the first house.
> The man who smokes Blend lives in the house next to the house with cats.
> In a house next to the house where they have a horse, they smoke Dunhill.
> The man who smokes Blue Master drinks beer.
> The German smokes Prince.
> The Norwegian lives next to the blue house.
> They drink water in a house next to the house where they smoke Blend.
>
>
> The question is, who owns the zebra?
>
> Additionally, list the solution for all the houses.
> Optionally, show the solution is unique.

newLISP

;; Iterate over all permutations of a list, and
;; call a function on each.
(define (permute permute.seq permute.func (permute.built '()))
(if (null? permute.seq)
(permute.func permute.built)
(let (seq (copy permute.seq))
(dotimes (i (length seq))
(unless (zero? i) (rotate seq -1))
(permute
(rest seq)
permute.func
(cons (first seq) permute.built))))))

(define (same-house obj0 lst0 obj1 lst1)
(= (find obj0 lst0) (find obj1 lst1)))

(define (distance obj0 lst0 obj1 lst1)
(- (find obj1 lst1) (find obj0 lst0)))

(define (next-to) (= 1 (abs (apply distance (args)))))

(permute '(danish english german norwegian swedish)
(fn (men)
(if (= 'norwegian (men 0))
(permute '(beer coffee milk tea water)
(fn (drinks)
(if (and (= 'milk (drinks 2))
(same-house 'danish men 'tea drinks))
(permute '(blue green red white yellow)
(fn (colors)
(if (and (= 1 (distance 'green colors 'white colors))
(same-house 'english men 'red colors)
(same-house 'coffee drinks 'green colors)
(next-to 'norwegian men 'blue colors))
(permute '(blend blue-master dunhill pall-mall prince)
(fn (smokes)
(if (and (same-house 'german men 'prince smokes)
(same-house 'dunhill smokes 'yellow colors)
(same-house 'blue-master smokes 'beer drinks)
(next-to 'water drinks 'blend smokes))
(permute '(birds cats dog horse zebra)
(fn (pets)
(if (and (same-house 'swedish men 'dog pets)
(same-house 'pall-mall smokes 'birds pets)
(next-to 'cats pets 'blend smokes)
(next-to 'horse pets 'dunhill smokes))
(println (transpose (list men drinks colors smokes pets)))
)))))))))))))))

((norwegian water yellow dunhill cats)
(danish tea blue blend horse)
(english milk red pall-mall birds)
(german coffee green prince zebra)
(swedish beer white blue-master dog))

Subject: Re: Zebra puzzle
From: steve g
Newsgroups: comp.lang.lisp
Date: Fri, 9 Aug 2024 21:59 UTC
References: 1
Path: eternal-september.org!news.eternal-september.org!feeder3.eternal-september.org!border-3.nntp.ord.giganews.com!border-4.nntp.ord.giganews.com!nntp.giganews.com!Xl.tags.giganews.com!local-1.nntp.ord.giganews.com!news.giganews.com.POSTED!not-for-mail
NNTP-Posting-Date: Fri, 09 Aug 2024 21:59:25 +0000
From: sgonedes1977@gmail.com (steve g)
Newsgroups: comp.lang.lisp
Subject: Re: Zebra puzzle
References: <v8s4o0$1bp29$1@dont-email.me>
Date: Fri, 09 Aug 2024 17:59:25 -0400
Message-ID: <871q2xtl1e.fsf@gmail.com>
User-Agent: Gnus/5.13 (Gnus v5.13)
Cancel-Lock: sha1:d63YdKf6t3KP1MHQTyXCQbdvHoc=
MIME-Version: 1.0
Content-Type: text/plain
Lines: 30
X-Usenet-Provider: http://www.giganews.com
X-Trace: sv3-RkIuetbIQscCgWRh90+jLznVroWAfWuU2udUlYQ7JmENA9XKHOHDLlbImBJjcRuBymc8N4F6+PGWBYn!IJ90hF8htOUWSIVCe/KiBDChUIgGuyjIaSoagcMBkbbSg+8=
X-Complaints-To: abuse@giganews.com
X-DMCA-Notifications: http://www.giganews.com/info/dmca.html
X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers
X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly
X-Postfilter: 1.3.40
View all headers

"B. Pym" <Nobody447095@here-nor-there.org> writes:

> Rosetta: Zebra puzzle
>
< > There are five houses.
< > The English man lives in the red house.
< > The Swede has a dog.
< > The Dane drinks tea.
< > The green house is immediately to the left of the white house.
< > They drink coffee in the green house.
< > The man who smokes Pall Mall has birds.
< > In the yellow house they smoke Dunhill.
< > In the middle house they drink milk.
< > The Norwegian lives in the first house.
< > The man who smokes Blend lives in the house next to the house with cats.
< > In a house next to the house where they have a horse, they smoke Dunhill.
< > The man who smokes Blue Master drinks beer.
< > The German smokes Prince.
< > The Norwegian lives next to the blue house.
< > They drink water in a house next to the house where they smoke Blend.
< >
< >
< > The question is, who owns the zebra?
< >
< > Additionally, list the solution for all the houses.
< > Optionally, show the solution is unique.
>

norvig covers this in his book; sorry for the wrong tank....

1

rocksolid light 0.9.8
clearnet tor