From 4ea90e11c765fe8948bf17f3bc01c8e8f74f9e1f Mon Sep 17 00:00:00 2001 From: Istvan Date: Tue, 11 Sep 2012 22:00:45 -0700 Subject: [PATCH] Adding Euler 32 --- src/euler/core.clj | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/euler/core.clj b/src/euler/core.clj index 6e922f9..9b05fd0 100644 --- a/src/euler/core.clj +++ b/src/euler/core.clj @@ -142,15 +142,21 @@ [n] (map char-int (str n))) - (defn multipl [] - (for - [a (range 1 999) - b (range 1 999)] - [a b (* a b)])) - - (defn asd [] ) - + (defn pandigital? + [x y z] + (= '(1 2 3 4 5 6 7 8 9) + (sort (apply concat (map digits [x y z]))))) + (defn euler32 + [] + (reduce + (distinct (for + ;the tricky part is to skip + ;the already calculated values, reduces runtime + [a (range 1 5000) + b (range a (/ 9999 a)) + :let [c (* a b)] + :when (pandigital? a b c)] + c)))) (ns maps-as-we-like)