public
Created

Clojure Dojo Tuesday, August 28, 2012

  • Download Gist
gistfile1.clj
Clojure
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
(ns dojo.core
(use clojure.string))
 
(def *input*
" _ _ _ _ _ _ _
| _| _||_||_ |_ ||_||_|
||_ _| | _||_| ||_| _|")
 
(def *zeros*
" _ _ _ _ _ _ _ _ _
| || || || || || || || || |
|_||_||_||_||_||_||_||_||_|")
 
(def *dic*
{
'(\space \_ \space \| \space \| \| \_ \|) 0
'(\space \space \space \space \space \| \space \space \|) 1
'(\space \_ \space \space \_ \| \| \_ \space) 2
'(\space \_ \space \space \_ \| \space \_ \|) 3
'(\space \space \space \| \_ \| \space \space \|) 4
'(\space \_ \space \| \_ \space \space \_ \|) 5
'(\space \_ \space \| \_ \space \| \_ \|) 6
'(\space \_ \space \space \space \| \space \space \|) 7
'(\space \_ \space \| \_ \| \| \_ \|) 8
'(\space \_ \space \| \_ \| \space \_ \|) 9
})
 
 
(defn break-to-9 [s]
(map #(partition 3 %) (split s #"\n")))
 
(defn conv [e]
(if (empty? (flatten e))
nil
(concat
(map first e)
(conv
(map rest e)))))
 
(defn proc-str [s]
(map #(get *dic* %) (map flatten (partition 3 (conv (break-to-9 s))))))

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.