Commits

Victor Iacoban  committed a2822c0

tweaking

  • Participants
  • Parent commits 6b23518

Comments (0)

Files changed (9)

File src/main/clojure/euler/prob001.clj

 (ns euler.prob001)
 
 (defn euler1 []
-  (reduce + (for [n (range 1 1000) :when (or (= 0 (mod n 3)) (= 0 (mod n 5)))] n)))
+  (reduce + (for [n (range 1 1000) :when (or (zero? (mod n 3)) (zero? (mod n 5)))] n)))

File src/main/clojure/euler/prob004.clj

   (read-string (str (str n) (clojure.string/reverse (str n)))))
 
 (defn is-acceptable? [p]
-  (seq (for [x (range 100 1000) :when (and (= 0 (mod p x)) (< (/ p x) 1000))] [x (/ p x)])))
+  (seq (for [x (range 100 1000) :when (and (zero? (mod p x)) (< (/ p x) 1000))] [x (/ p x)])))
 
 (defn euler4 []
   (first (filter is-acceptable? (reverse (map to-palindrome (range 100 1000))))))

File src/main/clojure/euler/prob006.clj

 (defn square [n] (* n n))
 
 (defn euler6 [n]
-    (- (square (* (+ n 1) (/ n 2))) (reduce + (map square (range 1 (inc n))))))
+    (- (square (* (inc n) (/ n 2))) (reduce + (map square (range 1 (inc n))))))
 

File src/main/clojure/euler/prob007.clj

   (:use tools.primes))
 
 (defn euler7 [n]
-  (take-last 1 (take n (for [x (primes-lazy-seq)] x))))
+  (take-last 1 (take n (primes-lazy-seq))))

File src/main/clojure/euler/prob008.clj

 (defn chop [input, c]
   (let [input-size (.length input)
         max-index (- input-size (dec c))]
-    (map #(.substring input % (+ c %)) (range 0 max-index))))
+    (map #(.substring input % (+ c %)) (range max-index))))
 
 (defn product-digits [s]
   (reduce * (map #(read-string (str %)) s)))

File src/main/clojure/euler/prob014.clj

 (def collatz-seq-memo)
 
 (defn collatz-seq [n]
-  (let [nx (if (even? n) (/ n 2) (+ 1 (* 3 n)))]
+  (let [nx (if (even? n) (/ n 2) (inc (* 3 n)))]
     (cond
       (= n 1) [1]
       (< n 0) nil

File src/main/clojure/euler/prob017.clj

                    (= 6 units) "sixteen"
                    (= 7 units) "seventeen"
                    (= 8 units) "eighteen"
-                   (= 9 units) "nineteen"
-                   :else "-------------------------------")
+                   (= 9 units) "nineteen")
 
       (= tens 2) (str "twenty" separator (number-to-words units))
       (= tens 3) (str "thirty" separator (number-to-words units))

File src/main/clojure/euler/prob018.clj

+(ns euler.prob018)
+
+(defn euler18 []
+  0)

File src/main/clojure/euler/prob025.clj

 
 (defn euler25 [n]
   (let [limit (.pow 10M (dec n))]
-    (+ 1 (count (take-while #(< % limit) (fibonacci-seq))))))
+    (inc (count (take-while #(< % limit) (fibonacci-seq))))))