Files
advent-of-code/2017/src/day01.clj
Adam Jeniski a889d088ae franz newline
2026-04-23 15:38:55 -04:00

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))