mirror of
https://github.com/Ajetski/advent-of-code.git
synced 2025-11-27 11:52:44 -10:00
format
This commit is contained in:
parent
aa99e18bd7
commit
63cd8c779c
@ -1,22 +1,16 @@
|
|||||||
(ns day19
|
(ns day19
|
||||||
(:require
|
(:require [clojure.string :as str]
|
||||||
[clojure.string :as str]
|
input-manager))
|
||||||
input-manager))
|
|
||||||
|
|
||||||
(let [[w _ & p]
|
(let [[w _ & p]
|
||||||
(input-manager/get-input 2024 19)]
|
(input-manager/get-input 2024 19)]
|
||||||
(def words (into #{} (str/split w #", ")))
|
(def words (into #{} (str/split w #", ")))
|
||||||
(def puzzles p)
|
(def puzzles p)
|
||||||
(def word-sizes (->> words
|
(def word-sizes (->> words (map count) distinct)))
|
||||||
(map count)
|
|
||||||
distinct)))
|
|
||||||
|
|
||||||
(defn valid-combination-count
|
(defn valid-combination-count
|
||||||
([puzzle]
|
([puzzle]
|
||||||
(valid-combination-count puzzle
|
(valid-combination-count puzzle 0 1 (mapv (constantly 0) 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]
|
;; 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]
|
([puzzle pos weight dp]
|
||||||
(if (>= pos (count puzzle))
|
(if (>= pos (count puzzle))
|
||||||
@ -31,12 +25,9 @@
|
|||||||
(recur puzzle (inc pos) (get dp' pos) dp')))))
|
(recur puzzle (inc pos) (get dp' pos) dp')))))
|
||||||
|
|
||||||
;; part 1 solution
|
;; part 1 solution
|
||||||
(->> puzzles
|
(->> (map valid-combination-count puzzles)
|
||||||
(map valid-combination-count)
|
|
||||||
(filter (partial < 0))
|
(filter (partial < 0))
|
||||||
count)
|
count)
|
||||||
|
|
||||||
;; part 2 solution
|
;; part 2 solution
|
||||||
(->> puzzles
|
(->> (map valid-combination-count puzzles) (apply +))
|
||||||
(map valid-combination-count)
|
|
||||||
(apply +))
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user