Created
November 16, 2019 16:49
-
-
Save chelseatroy/f9560ce9c417dda90c1432496dbd5819 to your computer and use it in GitHub Desktop.
Nondeterministic Logic Puzzle
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(try '(define multiple-dwelling | |
(lambda () | |
(define baker (amb 1 2 3 4 5)) | |
(define cooper (amb 1 2 3 4 5)) | |
(define fletcher (amb 1 2 3 4 5)) | |
(define miller (amb 1 2 3 4 5)) | |
(define smith (amb 1 2 3 4 5)) | |
(require | |
(distinct? (list baker cooper fletcher miller smith))) | |
(require (not (= baker 5))) | |
(require (not (= cooper 1))) | |
(require (not (= fletcher 5))) | |
(require (not (= fletcher 1))) | |
(require (> miller cooper)) | |
(require (not (= (abs (- smith fletcher)) 1))) | |
(require (not (= (abs (- fletcher cooper)) 1))) | |
(list (list 'baker baker) | |
(list 'cooper cooper) | |
(list 'fletcher fletcher) | |
(list 'miller miller) | |
(list 'smith smith)))) env) | |
(try '(multiple-dwelling) env) ; (('baker 3) ('cooper 2) ('fletcher 4) ('miller 5) ('smith 1)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment