2016/01/11
SICP 問題 4.41
多住居手続きをschemeで実装.
(use util.combinations)
(use srfi-1)
(define (multiple-dwelling)
(filter (lambda (x)
(let ((baker (first x))
(cooper (second x))
(fletcher (third x))
(miller (fourth x))
(smith (fifth x)))
(and
(not (= baker 5))
(not (= cooper 1))
(not (= fletcher 5))
(not (= fletcher 1))
(< cooper miller)
(not (= (abs (- smith fletcher)) 1))
(not (= (abs (- fletcher cooper)) 1)))))
(permutations '(1 2 3 4 5))))