Deutsch English Français Italiano |
<20240723231718.796@kylheku.com> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Kaz Kylheku <643-408-1753@kylheku.com> Newsgroups: comp.lang.lisp,comp.lang.scheme Subject: Re: Non-determinism Date: Wed, 24 Jul 2024 08:18:24 -0000 (UTC) Organization: A noiseless patient Spider Lines: 44 Message-ID: <20240723231718.796@kylheku.com> References: <v7pboq$1d67r$1@dont-email.me> <v7peea$1djes$1@dont-email.me> <v7q0m7$1jrar$1@dont-email.me> Injection-Date: Wed, 24 Jul 2024 10:18:24 +0200 (CEST) Injection-Info: dont-email.me; posting-host="22dbec4c97aef40d7cd38abdf24b02a3"; logging-data="1763569"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+cMESt+dRkbEokqQ1L2J/M5VH03FNTONc=" User-Agent: slrn/pre1.0.4-9 (Linux) Cancel-Lock: sha1:hFr4LbidT/oPXItvQ45jwPsiGDM= Bytes: 2304 On 2024-07-24, B. Pym <Nobody447095@here-nor-there.org> wrote: > B. Pym wrote: > >> Problem 4.42 in SICP >> >> Five school girls took an exam. As they think thattheir >> parents are too much interested in their score, they promise >> that they write one correct and one wrong informations to >> their parents. Followings are parts of their letters >> concerning their result: >> >> Betty: Kitty was the second and I third. >> Ethel: I won the top and Joan the second. >> Joan: I was the third and poor Ethel the last. >> Kitty: I was the second and Mary the fourth. >> Mary: I was the fourth. Betty won the top. >> >> Guess the real order of the five school girls. > > Shorter: [ snip astonishing 130 line continuation-driven spaghetti behemoth ] > ((kitty joan betty mary ethel)) $ txr girls.tl #(kitty joan betty mary ethel) $ cat girls.tl (defun one-truth (g i1 n1 i2 n2) (neq (eq [g i1] n1) (eq [g i2] n2))) (each ((g (perm #(kitty ethel joan mary betty) 5))) (when (and (one-truth g 1 'kitty 2 'betty) (one-truth g 0 'ethel 1 'joan) (one-truth g 2 'joan 4 'ethel) (one-truth g 1 'kitty 3 'mary) (one-truth g 3 'mary 0 'betty)) (prinl g))) -- TXR Programming Language: http://nongnu.org/txr Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal Mastodon: @Kazinator@mstdn.ca