From c3b0cff7542d7b643ce9f80ec16a9ea15935dc2e Mon Sep 17 00:00:00 2001 From: David Thompson Date: Sun, 2 Feb 2014 20:40:48 -0500 Subject: Clean up solution to problem 9. --- problem-9.scm | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'problem-9.scm') 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)) -- cgit v1.2.3