solution for problem 9 in racket

This commit is contained in:
Lowl3v3l 2017-05-09 21:53:02 +02:00
parent 04a8190ccb
commit 5f58ca8c87

14
9/euler9.rkt Normal file
View 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))))))