From 50772152056d122e17ccdcc8dc81ad332ed5f43e Mon Sep 17 00:00:00 2001 From: Adam Date: Sun, 26 Apr 2026 11:00:57 -0400 Subject: [PATCH] do 2017 day 5 --- 2017/src/day05.clj | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 2017/src/day05.clj diff --git a/2017/src/day05.clj b/2017/src/day05.clj new file mode 100644 index 0000000..a5b8f30 --- /dev/null +++ b/2017/src/day05.clj @@ -0,0 +1,30 @@ +(ns day05 + (:require input-manager)) + +(def input (->> (input-manager/get-input 2017 5) + (mapv parse-long))) + +(def MAX_IDX (count input)) + +;; part 1 +(loop [steps 0 + maze input + idx 0] + (let [maze' (update maze idx inc) + idx' (+ (maze idx) idx)] + (if (< -1 idx' MAX_IDX) + (recur (inc steps) maze' idx') + (inc steps)))) + +;; part 2 +(loop [steps 0 + maze input + idx 0] + (let [offset (maze idx) + maze' (update maze idx (if (>= offset 3) + dec + inc)) + idx' (+ offset idx)] + (if (< -1 idx' MAX_IDX) + (recur (inc steps) maze' idx') + (inc steps))))