Skip to content

Commit

Permalink
Merge pull request #79 from FrankKair/clojure-009
Browse files Browse the repository at this point in the history
Feat: Adds Clojure 009
  • Loading branch information
FrankKair authored Jun 27, 2018
2 parents 7d5a0b6 + ff5d19e commit d69d9de
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/009/p009.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
(defn square [x] (Math/pow x 2))

(defn sqrt [x] (Math/sqrt x))

(defn sum-1000? [x] (== 1000 (reduce + 0 x)))

(defn solve []
(let [candidates (for [b (range 700 5 -1), a (range 4 b)]
[a b (sqrt (+ (square a) (square b)))])]
(transduce (comp (filter sum-1000?)
cat
(map int))
* 1
candidates)))

(prn (solve))

0 comments on commit d69d9de

Please sign in to comment.