# danielfm/euler-clojure

Added the expected result to the source code.

1 parent bc207ed commit 6f18ebc48ff227ee83e1a5d271eb291dece05c60 committed Jul 4, 2009
1 euler/problem_1.clj
 @@ -8,4 +8,5 @@ "Finds the sum of all the multiples of 3 or 5 below 1000." (reduce + (filter (partial multiple-of-any? [3 5]) (range 1000)))) +; Expected result: 233168 (println (solve))
1 euler/problem_10.clj
 @@ -5,4 +5,5 @@ "Finds the sum of all the primes below two million." (reduce + (take-while #(< % 2000000) (filter prime? (iterate inc 1))))) +; Expected result: 142913828922 (println (solve))
3 euler/problem_11.clj
 @@ -21,4 +21,5 @@ (apply * (for [coord (calculate-coords [x y] t 4 s)] (reduce nth grid coord))))))) -(println (solve "euler/input/problem_11.txt")) +; Expected result: 70600674 +(println (solve "euler/input/problem_11.txt"))
3 euler/problem_12.clj
 @@ -10,4 +10,5 @@ "Returns the value of the first triangle number to have over five hundred divisors." (first (filter #(> (divisors %) 500) triangle-numbers))) -(println (solve)) +; Expected result: 76576500 +(println (solve))
3 euler/problem_13.clj
 @@ -9,4 +9,5 @@ "Returns the first ten digits of the sum of the following one-hundred 50-digit numbers." (apply str (take 10 (str (reduce + (load-input f)))))) -(println (solve "euler/input/problem_13.txt")) +; Expected result: 5537376230 +(println (solve "euler/input/problem_13.txt"))
1 euler/problem_14.clj
 @@ -24,4 +24,5 @@ (recur (dec n) n c) (recur (dec n) m lc)))))) +; Expected result: 837799 (println (solve))
3 euler/problem_15.clj
 @@ -6,4 +6,5 @@ (let [dim 20] (k-comb (* dim 2) dim))) -(println (solve)) +; Expected result: 137846528820 +(println (solve))
3 euler/problem_16.clj
 @@ -6,4 +6,5 @@ "Returns the sum of the digits of the number 2^1000." (reduce + (map to-int (str (expt 2 1000))))) -(println (solve)) +; Expected result: 1366 +(println (solve))
3 euler/problem_17.clj
 @@ -26,4 +26,5 @@ "Returns the number of letters used to write in words all the numbers from 1 to 1000." (reduce + (map count (map n-in-words (range 1 1001))))) -(println (solve)) +; Expected result: 21124 +(println (solve))
3 euler/problem_2.clj
 @@ -5,4 +5,5 @@ "Finds the sum of all the even-valued terms in the Fibbonacci sequence which do not exceed four million." (reduce + (filter even? (take-while #(<= % 4000000) (fibs))))) -(println (solve)) +; Expected result: 4613732 +(println (solve))
3 euler/problem_20.clj
 @@ -5,4 +5,5 @@ "Find the sum of digits in 100!" (reduce + (map to-int (str (fact 100))))) -(println (solve)) +; Expected result: 648 +(println (solve))
1 euler/problem_3.clj
 @@ -10,4 +10,5 @@ i (recur (dec i)))))) +; Expected result: 6857 (println (solve))
3 euler/problem_4.clj
 @@ -9,4 +9,5 @@ "Returns the largest palindrome made from the product of two 3-digit numbers." (apply max (filter palindrome? (for [a (range 100 1000) b (range a 1000)] (* a b))))) -(println (solve)) +; Expected result: 906609 +(println (solve))
1 euler/problem_5.clj
 @@ -5,4 +5,5 @@ "Returns the smallest number that is evenly divisible by all of the numbers from 1 to 20?" (reduce lcm (range 1 21))) +; Expected result: 232792560 (println (solve))
1 euler/problem_6.clj
 @@ -14,4 +14,5 @@ (let [coll (range 1 101)] (- (square-of-the-sum coll) (sum-of-squares coll)))) +; Expected result: 25164150 (println (solve))
3 euler/problem_7.clj
 @@ -5,4 +5,5 @@ "Returns the 1001st prime number." (nth primes 10000)) -(println (solve)) +; Expected result: 104743 +(println (solve))
3 euler/problem_8.clj
 @@ -9,4 +9,5 @@ "Returns the greatest product of five consecutive digits in the 1000-digit number" (apply max (map #(reduce * %) (partition 5 1 (load-input f))))) -(println (solve "euler/input/problem_8.txt")) +; Expected result: 40824 +(println (solve "euler/input/problem_8.txt"))
3 euler/problem_9.clj
 @@ -6,4 +6,5 @@ :when (= (+ (* a a) (* b b)) (* c c))] (* a b c)))) -(println (solve)) +; Expected result: 31875000 +(println (solve))