init 2017
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
(ns day01
|
||||
(:require input-manager))
|
||||
|
||||
(defn to-digit [c] (Character/digit c 10))
|
||||
|
||||
(def input (mapv to-digit (input-manager/get-input-raw 2017 01)))
|
||||
|
||||
(defn solve [offset]
|
||||
(let [lookup (fn [idx]
|
||||
(input (mod idx (count input))))]
|
||||
(->> input
|
||||
(map-indexed vector)
|
||||
(filter (fn [[idx el]]
|
||||
(= el (lookup (+ offset idx)))))
|
||||
(map second)
|
||||
(apply +))))
|
||||
|
||||
;; part 1
|
||||
(solve 1)
|
||||
|
||||
|
||||
|
||||
;; part 2
|
||||
(solve (/ (count input) 2))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user