solution for problem 9 in racket
This commit is contained in:
parent
04a8190ccb
commit
5f58ca8c87
1 changed files with 14 additions and 0 deletions
14
9/euler9.rkt
Normal file
14
9/euler9.rkt
Normal file
|
@ -0,0 +1,14 @@
|
|||
#lang racket
|
||||
|
||||
|
||||
(define squarenums (map (λ (x) (* x x)) (range 1 500)))
|
||||
|
||||
(define squaresums
|
||||
(for/list ((i squarenums))
|
||||
(for/list ((j (cdr squarenums)))
|
||||
(list (+ i j) i j))))
|
||||
|
||||
(apply * (map sqrt
|
||||
(first (filter
|
||||
(λ (x) (equal? 1000 (+ (sqrt (first x)) (sqrt (second x)) (sqrt (third x)))))
|
||||
(filter (λ (x) (member (first x) squarenums)) (apply append squaresums))))))
|
Reference in a new issue