Câu trả lời của tôi cho điều này problem cảm thấy quá nhiều như thế này solutions in C.Dự án Euler # 9 (Bộ ba Pythagore) trong Clojure
Có ai có lời khuyên nào để làm điều này trở nên đáng sợ hơn không?
(use 'clojure.test)
(:import 'java.lang.Math)
(with-test
(defn find-triplet-product
([target] (find-triplet-product 1 1 target))
([a b target]
(let [c (Math/sqrt (+ (* a a) (* b b)))]
(let [sum (+ a b c)]
(cond
(> a target) "ERROR"
(= sum target) (reduce * (list a b (int c)))
(> sum target) (recur (inc a) 1 target)
(< sum target) (recur a (inc b) target))))))
(is (= (find-triplet-product 1000) 31875000)))
lớn tài nguyên ... nhờ. – dbyrne
+1 cho liên kết! –