This repository has been archived on 2024-01-26. You can view files and clone it, but cannot push or open issues or pull requests.
project-euler/e0009/euler0009.rkt

14 lines
435 B
Racket
Raw Normal View History

2017-05-09 21:53:02 +02:00
#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))))))