source: project/release/4/amb/trunk/amb-dwelling.scm @ 13799

Last change on this file since 13799 was 13799, checked in by Kon Lovett, 12 years ago

Save.

File size: 1.5 KB
Line 
1#|
2Baker, Cooper, Fletcher, Miller, and Smith live on different
3floors of an apartment house that contains only five floors. Baker
4does not live on the top floor. Cooper does not live on the bottom
5floor. Fletcher does not live on either the top or the bottom
6floor. Miller lives on a higher floor than does Cooper. Smith does not
7live on a floor adjacent to Fletcher's. Fletcher does not live on a
8floor adjacent to Cooper's. Where does everyone live?
9|#
10
11(define (multiple-dwelling)
12  (let ((baker  (amb 1 2 3 4 5))
13        (cooper (amb 1 2 3 4 5))
14        (fletcher  (amb 1 2 3 4 5))
15        (miller (amb 1 2 3 4 5))
16        (smith  (amb 1 2 3 4 5)))
17    ;; They live on different floors.
18    (require
19      (distinct? (list baker cooper fletcher miller smith)))
20
21    ;; Baker does not live on the top floor.
22    (require (not (= baker 5)))
23
24    ;; Cooper does not live on the bottom floor.
25    (require (not (= cooper 1)))
26
27    ;; Fletcher does not live on either the top
28    ;; or the bottom floor.
29    (require (not (= fletcher 5)))
30    (require (not (= fletcher 1)))
31
32    ;; Miller lives on a higher floor than does Cooper.
33    (require (> miller cooper))
34
35    ;; Smith does not live on a floor adjacent to Fletcher's.
36    (require (not (= (abs (- smith fletch)) 1)))
37
38    ;; Fletcher does not live on a floor adjacent to Cooper's.
39    (require (not (= (abs (- fletcher cooper)) 1)))
40
41    (list (list 'baker baker)
42          (list 'cooper cooper)
43          (list 'fletcher fletcher)
44          (list 'miller miller)
45          (list 'smith smith))))
Note: See TracBrowser for help on using the repository browser.