From cdde63a7977e365e4a53ace6ad5037a5ba79b015 Mon Sep 17 00:00:00 2001 From: Clyne Sullivan Date: Wed, 8 Dec 2021 09:55:12 -0500 Subject: add day 8 --- day8/part1.clj | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 day8/part1.clj (limited to 'day8/part1.clj') diff --git a/day8/part1.clj b/day8/part1.clj new file mode 100644 index 0000000..6c8cd0f --- /dev/null +++ b/day8/part1.clj @@ -0,0 +1,28 @@ +(require '[clojure.string :as str]) + +(loop [sum 0] + (let [line (read-line)] + (if (empty? line) + (println sum) + (recur + (+ + sum + (reduce + #(let [c (count %2)] + (if (or (= 2 c) (= 3 c) (= 4 c) (= 7 c)) + (inc %1) + %1 + ) + ) + 0 + (subvec + (mapv (comp str/join sort) (str/split line #" ")) + 11 15 + ) + ) + ) + ) + ) + ) + ) + -- cgit v1.2.3