golf
This commit is contained in:
parent
56a1bed93d
commit
50e6464eba
@ -24,19 +24,15 @@
|
||||
|
||||
(def input (map parse-line (input-manager/get-input 2025 10)))
|
||||
|
||||
(defn apply-ops [v ops]
|
||||
(reduce (fn [acc op]
|
||||
(reduce #(update %1 %2 not) acc op))
|
||||
v
|
||||
ops))
|
||||
|
||||
(defn minimum-button-mashing [{ops :buttons v :indicators}]
|
||||
(defn minimum-button-mashing [{:keys [buttons indicators]}]
|
||||
(loop [i 0
|
||||
cnt 1]
|
||||
(if (>= i (combo/count-combinations ops cnt))
|
||||
(if (>= i (combo/count-combinations buttons cnt))
|
||||
(recur 0 (inc cnt))
|
||||
(let [v' (apply-ops v (combo/nth-combination ops cnt i))]
|
||||
(if (every? (complement identity) v')
|
||||
(let [indicators' (reduce (partial reduce #(update %1 %2 not))
|
||||
indicators
|
||||
(combo/nth-combination buttons cnt i))]
|
||||
(if (every? (complement identity) indicators')
|
||||
cnt
|
||||
(recur (inc i) cnt))))))
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user