|
|
@ -8,17 +8,17 @@
|
|
|
|
digits in `cnts` with `grp-to-cmp` segments.
|
|
|
|
digits in `cnts` with `grp-to-cmp` segments.
|
|
|
|
"
|
|
|
|
"
|
|
|
|
[segs-left dig-to-cmp cnts grp-to-cmp]
|
|
|
|
[segs-left dig-to-cmp cnts grp-to-cmp]
|
|
|
|
(second
|
|
|
|
(as-> cnts $
|
|
|
|
(first
|
|
|
|
(filterv #(= (first %) grp-to-cmp) $)
|
|
|
|
(filter
|
|
|
|
(filterv
|
|
|
|
#(-> (second %)
|
|
|
|
#(-> (second %)
|
|
|
|
(str/replace (re-pattern (str/join ["[" dig-to-cmp "]"])) "")
|
|
|
|
(str/replace (re-pattern (str/join ["[" dig-to-cmp "]"])) "")
|
|
|
|
(count)
|
|
|
|
(count)
|
|
|
|
(= segs-left)
|
|
|
|
(= segs-left)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
(filterv #(= (first %) grp-to-cmp) cnts)
|
|
|
|
$
|
|
|
|
)
|
|
|
|
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
(get-in $ [0 1])
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
@ -31,27 +31,27 @@
|
|
|
|
7 (mcounts 3)
|
|
|
|
7 (mcounts 3)
|
|
|
|
8 (mcounts 7)
|
|
|
|
8 (mcounts 7)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
(assoc $ 3 (find-match 2 ($ 7) counts 5))
|
|
|
|
(assoc $ 3 (find-match 2 ($ 7) counts 5)
|
|
|
|
(assoc $ 2 (find-match 3 ($ 4) counts 5))
|
|
|
|
6 (find-match 4 ($ 7) counts 6)
|
|
|
|
|
|
|
|
2 (find-match 3 ($ 4) counts 5)
|
|
|
|
|
|
|
|
9 (find-match 2 ($ 4) counts 6)
|
|
|
|
|
|
|
|
)
|
|
|
|
(assoc $ 5 (find-match 2 ($ 2) counts 5))
|
|
|
|
(assoc $ 5 (find-match 2 ($ 2) counts 5))
|
|
|
|
(assoc $ 0 (find-match 2 ($ 5) counts 6))
|
|
|
|
(assoc $ 0 (find-match 2 ($ 5) counts 6))
|
|
|
|
(assoc $ 9 (find-match 2 ($ 4) counts 6))
|
|
|
|
|
|
|
|
(assoc $ 6 (find-match 4 ($ 7) counts 6))
|
|
|
|
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
(loop [sum 0]
|
|
|
|
(println
|
|
|
|
(let [rl (read-line)]
|
|
|
|
(reduce
|
|
|
|
(if (empty? rl)
|
|
|
|
(fn [sum input]
|
|
|
|
(println sum)
|
|
|
|
(let [line (as-> input $
|
|
|
|
(let [line (as-> rl $
|
|
|
|
|
|
|
|
(str/split $ #" ")
|
|
|
|
(str/split $ #" ")
|
|
|
|
(mapv (comp str/join sort) $)
|
|
|
|
(mapv (comp str/join sort) $)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
number (subvec line 11 15)
|
|
|
|
number (subvec line 11 15)
|
|
|
|
decoder (set/map-invert (determine-digits line))]
|
|
|
|
decoder (set/map-invert (determine-digits line))]
|
|
|
|
(recur (->> number
|
|
|
|
(->> number
|
|
|
|
(map (comp str decoder))
|
|
|
|
(map (comp str decoder))
|
|
|
|
(str/join)
|
|
|
|
(str/join)
|
|
|
|
(#(Integer/parseInt %))
|
|
|
|
(#(Integer/parseInt %))
|
|
|
@ -59,7 +59,8 @@
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
0
|
|
|
|
|
|
|
|
(str/split-lines (slurp "./in"))
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|