this repo has no description

(D4P1): Solution

+46
+10
resources/04-test.txt
··· 1 + ..@@.@@@@. 2 + @@@.@.@.@@ 3 + @@@@@.@.@@ 4 + @.@@@@..@. 5 + @@.@@@@.@@ 6 + .@@@@@@@.@ 7 + .@.@.@.@@@ 8 + @.@@@.@@@@ 9 + .@@@@@@@@. 10 + @.@.@@@.@.
+36
src/aoc2025/day4.clj
··· 1 + (ns aoc2024.day4 2 + (:require [aoc2025.util :as util] 3 + [clojure.string :as str])) 4 + 5 + (defn- parse-file [fname] 6 + (->> fname util/read-file util/gridify)) 7 + 8 + (defn- part1 [grid] 9 + (let [height (-> grid count) 10 + width (-> grid first count) 11 + paper? (partial = \@)] 12 + (count 13 + (for [idy (range height) 14 + idx (range width) 15 + :let [pos [idy idx] 16 + cell (get-in grid pos) 17 + adjacent-cells (->> pos util/adj+ 18 + (filter #(every? (util/between? 0 (dec width)) %)) 19 + (map #(get-in grid %))) 20 + adjacent-paper-count (->> adjacent-cells (filter paper?) count)] 21 + :when 22 + (and (paper? cell) 23 + (< adjacent-paper-count 4))] 24 + pos)))) 25 + 26 + (defn- part2 [grid]) 27 + 28 + (defn solve 29 + ([] (solve "04.txt")) 30 + ([fname] 31 + (->> (parse-file fname) ((juxt part1 part2))))) 32 + 33 + (solve "04-test.txt") 34 + 35 + (solve) ; => 1363 36 +