Created
July 20, 2013 02:07
-
-
Save ayato-p/6043545 to your computer and use it in GitHub Desktop.
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
(define (doctor-away-numbers? a b c) | |
(let ((b1 (div b 10)) | |
(b2 (mod b 10)) | |
(c1 (div c 10)) | |
(c2 (mod c 10))) | |
(and (= (+ (* (div b2 a) 10) | |
(/ (+ (* b1 10) (div b2 a)) a)) | |
c) | |
(= (apply + | |
(append | |
(make-list c1 a) | |
(make-list c2 a))) | |
b) | |
(= (+ (* c1 a) (* c2 a)) | |
b)))) | |
(let loop ((a 1) (b 10) (c 10) (ans '())) | |
(cond [(= a 10) ans] | |
[(= b 100) (loop (+ a 1) 10 10 ans)] | |
[(= c 100) (loop a (+ b 1) 10 ans)] | |
[else (loop a b (+ c 1) (if (doctor-away-numbers? a b c) | |
(cons `(,a ,b ,c) ans) | |
ans))])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment