Created
October 27, 2013 17:02
-
-
Save johnwalker/7185026 to your computer and use it in GitHub Desktop.
Incomplete
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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