|
|
@ -3,19 +3,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
(defn check-line [input]
|
|
|
|
(defn check-line [input]
|
|
|
|
(loop [in input open '()]
|
|
|
|
(loop [in input open '()]
|
|
|
|
(cond
|
|
|
|
(if-let [c (first in)]
|
|
|
|
(empty? in)
|
|
|
|
(when (or (nil? (#{\} \) \] \>} c)) (= (first open) c))
|
|
|
|
(map to-closing open)
|
|
|
|
|
|
|
|
(and (contains? #{\} \) \] \>} (first in))
|
|
|
|
|
|
|
|
(not= (to-closing (first open)) (first in)))
|
|
|
|
|
|
|
|
nil
|
|
|
|
|
|
|
|
:else
|
|
|
|
|
|
|
|
(recur
|
|
|
|
(recur
|
|
|
|
(rest in)
|
|
|
|
(rest in)
|
|
|
|
(if (contains? #{\{ \( \[ \<} (first in))
|
|
|
|
(if-let [op (to-closing c)]
|
|
|
|
(conj open (first in))
|
|
|
|
(conj open op)
|
|
|
|
(rest open)
|
|
|
|
(rest open))))
|
|
|
|
)))))
|
|
|
|
open
|
|
|
|
|
|
|
|
)))
|
|
|
|
|
|
|
|
|
|
|
|
(->> (slurp "./in")
|
|
|
|
(->> (slurp "./in")
|
|
|
|
(clojure.string/split-lines)
|
|
|
|
(clojure.string/split-lines)
|
|
|
|