diff --git a/2023/src/day01.clj b/2023/src/day01.clj index c3d71e8..0cda77e 100644 --- a/2023/src/day01.clj +++ b/2023/src/day01.clj @@ -12,15 +12,10 @@ (re-find #"\d" (string/reverse %))))) (reduce +)) -(def numeric-value-map {"one" 1 - "two" 2 - "three" 3 - "four" 4 - "five" 5 - "six" 6 - "seven" 7 - "eight" 8 - "nine" 9}) +(def numeric-value-map + (->> ["one" "two" "three" "four" "five" "six" "seven" "eight" "nine"] + (map-indexed (fn [idx val] [val (inc idx)])) + (into {}))) (defn numeric-value [s] (or (numeric-value-map s) s))