|
|
@ -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)
|
|
|
|
(recur
|
|
|
|
(and (contains? #{\} \) \] \>} (first in))
|
|
|
|
(rest in)
|
|
|
|
(not= (to-closing (first open)) (first in)))
|
|
|
|
(if-let [op (to-closing c)]
|
|
|
|
nil
|
|
|
|
(conj open op)
|
|
|
|
:else
|
|
|
|
(rest open))))
|
|
|
|
(recur
|
|
|
|
open
|
|
|
|
(rest in)
|
|
|
|
)))
|
|
|
|
(if (contains? #{\{ \( \[ \<} (first in))
|
|
|
|
|
|
|
|
(conj open (first in))
|
|
|
|
|
|
|
|
(rest open)
|
|
|
|
|
|
|
|
)))))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(->> (slurp "./in")
|
|
|
|
(->> (slurp "./in")
|
|
|
|
(clojure.string/split-lines)
|
|
|
|
(clojure.string/split-lines)
|
|
|
|