Created
December 1, 2017 22:45
Advent of Code 2017: Day 01
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
(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