Skip to content

Instantly share code, notes, and snippets.

@johnwalker
Created October 27, 2013 17:02
Show Gist options
  • Save johnwalker/7185026 to your computer and use it in GitHub Desktop.
Save johnwalker/7185026 to your computer and use it in GitHub Desktop.
Incomplete
(ns ieee2013.subst)
(defn make-encoding [w c]
(if (= (count c) (count w))
(map-indexed (fn [n x] {(nth w n) (nth c n)})
w)))
(let [input
"2
case
simple
AJWHPU GXAU"
parsed-input (vec (filter (complement empty?)
(clojure.string/split input #"\n")))
num-words (read-string (first parsed-input))
words (vec (filter (complement empty?)
(mapv clojure.string/trim
(butlast (rest parsed-input)))))
cipher (clojure.string/split (clojure.string/trim (last parsed-input)) #" ")
sword (vec (sort-by count words))
scipher (vec (sort-by count cipher))
word-l (frequencies (map count sword))]
(map make-encoding sword scipher)
word-l)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment