diff options
author | David Thompson <dthompson2@worcester.edu> | 2014-02-02 20:40:48 -0500 |
---|---|---|
committer | David Thompson <dthompson2@worcester.edu> | 2014-02-02 20:40:48 -0500 |
commit | c3b0cff7542d7b643ce9f80ec16a9ea15935dc2e (patch) | |
tree | e16603e2260f82323f4cacf6131c4919051f1830 | |
parent | 23355128183a19f1b8e983bdf50a3ea2f1a07fb2 (diff) |
Clean up solution to problem 9.
-rw-r--r-- | problem-9.scm | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/problem-9.scm b/problem-9.scm index cc0b862..152a6aa 100644 --- a/problem-9.scm +++ b/problem-9.scm @@ -5,21 +5,21 @@ (* x x)) ;; Euclid's formula. -(define (generate-triple n m) +(define (make-triple n m) (list (- (square n) (square m)) (* 2 n m) (+ (square n) (square m)))) -(define (generate-triples max-n max-m) +(define (generate-triples max-n) (concatenate (list-ec (:range n 2 max-n) (list-ec (:range m 1 (1- n)) - (generate-triple n m))))) + (make-triple n m))))) (define (find-triple-sum goal) (find (lambda (triple) (= (apply + triple) goal)) - ;; Assumed that this range would be enough. :) - (generate-triples 100 99))) + ;; Assumed that a range of 50 would be enough. + (generate-triples 50))) (apply * (find-triple-sum 1000)) |