24 lines
508 B
Clojure
24 lines
508 B
Clojure
(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))
|
|
|