Sysop: | Amessyroom |
---|---|
Location: | Fayetteville, NC |
Users: | 23 |
Nodes: | 6 (0 / 6) |
Uptime: | 52:43:39 |
Calls: | 583 |
Files: | 1,139 |
D/L today: |
179 files (27,921K bytes) |
Messages: | 111,617 |
Baker does not live on the top floor.
Cooper does not live on the bottom floor.
Fletcher does not live on either the top or the bottom floor.
Miller lives on a higher floor than does Cooper.
Smith does not live on a floor adjacent to Fletcher's.
Fletcher does not live on a floor adjacent to Cooper's.
Baker does not live on the top floor.
Cooper does not live on the bottom floor.
Fletcher does not live on either the top or the bottom floor.
Miller lives on a higher floor than does Cooper.
Smith does not live on a floor adjacent to Fletcher's.
Fletcher does not live on a floor adjacent to Cooper's.
Gauche Scheme
(use util.combinations) ;; permutations
(use srfi-1) ;; list-index
(define (index x xs) (list-index (cut equal? <> x) xs))
(define (apart a b xs) (< 1 (abs (- (index a xs) (index b xs)))))
(define men
`((baker . ,(iota 4))
(cooper . ,(iota 4 1))
(fletcher . ,(iota 3 1))
(miller . ,(lrange 2 5))
(smith . ,(iota 5))))
(dolist (perm (permutations (map car men)))
(when
(and
(every
(lambda(man) (member (index man perm) (assoc-ref men man)))
perm)
(> (index 'miller perm) (index 'cooper perm))
(apart 'smith 'fletcher perm)
(apart 'cooper 'fletcher perm))
(print perm)))
(smith cooper baker fletcher miller)
Baker does not live on the top floor.
Cooper does not live on the bottom floor.
Fletcher does not live on either the top or the bottom floor.
Miller lives on a higher floor than does Cooper.
Smith does not live on a floor adjacent to Fletcher's.
Fletcher does not live on a floor adjacent to Cooper's.
Gauche Scheme
(use util.combinations) ;; permutations
(use srfi-1) ;; list-index
(define (index x xs) (list-index (cut equal? <> x) xs))
(define (apart a b xs) (< 1 (abs (- (index a xs) (index b xs)))))
(define men
`((baker . ,(iota 4))
(cooper . ,(iota 4 1))
(fletcher . ,(iota 3 1))
(miller . ,(lrange 2 5))
(smith . ,(iota 5))))
(dolist (perm (permutations (map car men)))
(when
(and
(every
(lambda(man) (member (index man perm) (assoc-ref men man)))
perm)
(> (index 'miller perm) (index 'cooper perm))
(apart 'smith 'fletcher perm)
(apart 'cooper 'fletcher perm))
(print perm)))
(smith cooper baker fletcher miller)