;;;; amb-dwelling.scm (import scheme (chicken base) amb amb-extras) ;; Baker, Cooper, Fletcher, Miller, and Smith live on different ;; floors of an apartment house that contains only five floors. 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. ;; ;; Where does everyone live? (define (solve-dwelling-puzzle) (let ((baker (amb 1 2 3 4 5)) (cooper (amb 1 2 3 4 5)) (fletcher (amb 1 2 3 4 5)) (miller (amb 1 2 3 4 5)) (smith (amb 1 2 3 4 5)) ) (required ; They live on different floors. (distinct? (list baker cooper fletcher miller smith)) ; Baker does not live on the top floor. (not (= baker 5)) ; Cooper does not live on the bottom floor. (not (= cooper 1)) ; Fletcher does not live on either the top or the bottom floor. (not (= fletcher 5)) (not (= fletcher 1)) ; Miller lives on a higher floor than does Cooper. (> miller cooper) ; Smith does not live on a floor adjacent to Fletcher's. (not (= (abs (- smith fletcher)) 1)) ; Fletcher does not live on a floor adjacent to Cooper's. (not (= (abs (- fletcher cooper)) 1)) ) `((baker ,baker) (cooper ,cooper) (fletcher ,fletcher) (miller ,miller) (smith ,smith))) )