Skip to content

Instantly share code, notes, and snippets.

@selfsame
Created December 13, 2013 20:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save selfsame/7951119 to your computer and use it in GitHub Desktop.
Save selfsame/7951119 to your computer and use it in GitHub Desktop.
; 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