Skip to content

Instantly share code, notes, and snippets.

@ksaua
Created February 20, 2015 07:28
Show Gist options
  • Save ksaua/e0bf867531d420821133 to your computer and use it in GitHub Desktop.
Save ksaua/e0bf867531d420821133 to your computer and use it in GitHub Desktop.
Bank ocr
(require '[clojure.string :as str])
(def characters (apply str
" _ _ _ _ _ _ _ _ \n"
"| | | _| _||_||_ |_ ||_||_|\n"
"|_| ||_ _| | _||_| ||_| _|\n"
" \n"))
(defn chunk3 [line]
(->> (partition 3 line)
(map #(apply str %1))))
(defn transpose [lst]
(apply mapv vector lst))
(def all-numbers
(->> characters
(str/split-lines)
(map chunk3)
(transpose)
(map-indexed vector)
(map (fn[[a b]] [b a]))
(into {})))
(defn ocrToNumber [ocr]
(->> ocr
(str/split-lines)
(map chunk3)
(transpose)
(map #(get all-numbers %1))))
(def toOcr (apply str
" _ _ \n"
" ||_||_||_ \n"
" ||_| ||_|\n"
" \n"))
(println toOcr)
(println (ocrToNumber toOcr))
@abingham
Copy link

It's 1.5.1 on OS X.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment