mirror of
https://github.com/Ajetski/advent-of-code.git
synced 2025-11-27 11:32:45 -10:00
format
This commit is contained in:
parent
aa99e18bd7
commit
63cd8c779c
@ -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 +))
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user