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)))
|
(def input (map parse-line (input-manager/get-input 2025 10)))
|
||||||
|
|
||||||
(defn apply-ops [v ops]
|
(defn minimum-button-mashing [{:keys [buttons indicators]}]
|
||||||
(reduce (fn [acc op]
|
|
||||||
(reduce #(update %1 %2 not) acc op))
|
|
||||||
v
|
|
||||||
ops))
|
|
||||||
|
|
||||||
(defn minimum-button-mashing [{ops :buttons v :indicators}]
|
|
||||||
(loop [i 0
|
(loop [i 0
|
||||||
cnt 1]
|
cnt 1]
|
||||||
(if (>= i (combo/count-combinations ops cnt))
|
(if (>= i (combo/count-combinations buttons cnt))
|
||||||
(recur 0 (inc cnt))
|
(recur 0 (inc cnt))
|
||||||
(let [v' (apply-ops v (combo/nth-combination ops cnt i))]
|
(let [indicators' (reduce (partial reduce #(update %1 %2 not))
|
||||||
(if (every? (complement identity) v')
|
indicators
|
||||||
|
(combo/nth-combination buttons cnt i))]
|
||||||
|
(if (every? (complement identity) indicators')
|
||||||
cnt
|
cnt
|
||||||
(recur (inc i) cnt))))))
|
(recur (inc i) cnt))))))
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user