Created
December 13, 2013 20:51
-
-
Save selfsame/7951119 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; Problem 1 WRONG ANSWER | |
(defn accept-n [n] | |
(cond (== 0 (mod n 3)) n | |
(== 0 (mod n 5)) n | |
:else 0)) | |
; First used inc 0 and take 999, off by one :( | |
; Not sure why it's still messing up | |
(apply + (map accept-n (take 1000 (iterate inc 1)))) | |
; Problem 2 | |
(def s [1 2]) | |
s | |
(conj s 45) | |
(nth s (- (count s) 2)) | |
(defn problem-2 [] | |
(while (< (last s) 4000000) | |
(def s | |
(conj s | |
(+ | |
(nth s (- (count s) 2)) | |
(last s)))) ) | |
(apply + (remove odd? (pop s)))) | |
(problem-2) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment