diff --git a/2024/src/day19.clj b/2024/src/day19.clj index 57f7240..7dbf40c 100644 --- a/2024/src/day19.clj +++ b/2024/src/day19.clj @@ -1,22 +1,16 @@ (ns day19 - (:require - [clojure.string :as str] - input-manager)) + (:require [clojure.string :as str] + input-manager)) (let [[w _ & p] (input-manager/get-input 2024 19)] (def words (into #{} (str/split w #", "))) (def puzzles p) - (def word-sizes (->> words - (map count) - distinct))) + (def word-sizes (->> words (map count) distinct))) (defn valid-combination-count ([puzzle] - (valid-combination-count puzzle - 0 - 1 - (mapv (constantly 0) puzzle))) + (valid-combination-count puzzle 0 1 (mapv (constantly 0) puzzle))) ;; dp is vec of ints which contains the count of combinations for substring from puzzle[0] and ending at puzzle[n] ([puzzle pos weight dp] (if (>= pos (count puzzle)) @@ -31,12 +25,9 @@ (recur puzzle (inc pos) (get dp' pos) dp'))))) ;; part 1 solution -(->> puzzles - (map valid-combination-count) +(->> (map valid-combination-count puzzles) (filter (partial < 0)) count) ;; part 2 solution -(->> puzzles - (map valid-combination-count) - (apply +)) +(->> (map valid-combination-count puzzles) (apply +))