From d20125b66e35d3380e4e39c4a75fbb6604b6cc00 Mon Sep 17 00:00:00 2001 From: Leah Neukirchen Date: Fri, 4 Dec 2020 12:38:16 +0100 Subject: day03 --- day03.clj | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 day03.clj (limited to 'day03.clj') diff --git a/day03.clj b/day03.clj new file mode 100644 index 0000000..16981d1 --- /dev/null +++ b/day03.clj @@ -0,0 +1,15 @@ +(def data + (->> (slurp "day03") + (clojure.string/split-lines)) + +(defn slop [step] + (->> (range) + (map #(mapv (partial * %) step)) + (take-while #(< (first %) (count data))) + (map (fn [[x y]] + (nth (cycle (nth data x)) y))) + (filter #{\#}) + (count))) + +(slop [1 3]) ; => 270 +(apply * (map slop [[1 1] [1 3] [1 5] [1 7] [2 1]])) ; => 2122848000 -- cgit 1.4.1