diff options
-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)) |