From 50e6464eba24ba652b55ed35a8f2bb94d7148228 Mon Sep 17 00:00:00 2001 From: ajet Date: Fri, 12 Dec 2025 12:19:40 -1000 Subject: [PATCH] golf --- 2025/src/day10.clj | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/2025/src/day10.clj b/2025/src/day10.clj index 5036328..9e7d134 100644 --- a/2025/src/day10.clj +++ b/2025/src/day10.clj @@ -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))))))