Skip to content

Instantly share code, notes, and snippets.

@pmbauer
Created December 1, 2017 22:45
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 pmbauer/582d77c33c81639908f387ff8ddd9586 to your computer and use it in GitHub Desktop.
Save pmbauer/582d77c33c81639908f387ff8ddd9586 to your computer and use it in GitHub Desktop.
Advent of Code 2017: Day 01
(def input (->> "1122"
(map #(Integer/parseInt (str %)))
(into [])))
(defn captcha [coll offset]
(transduce (comp (filter #(apply = %))
(map first))
+
(mapv vector coll (->> (cycle coll)
(drop offset)
(take (count coll))))))
;; part 1
(captcha input 1)
;; part 2
(captcha input (/ (count input) 2))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment