diff --git a/day8/part1.clj b/day8/part1.clj index 6c8cd0f..fe06fdf 100644 --- a/day8/part1.clj +++ b/day8/part1.clj @@ -1,28 +1,15 @@ (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 - ) - ) - ) - ) - ) - ) - ) +(->> (str/split-lines (slurp "./in")) + (map + (fn [line] + (as-> line $ + (str/split $ #" ") + (subvec $ 11 15) + (filter #(.contains [2 3 4 7] (count %)) $) + (count $) + ))) + (apply +) + (println) + )