Created
November 9, 2019 04:43
-
-
Save ampersanda/a58ca3bfcf0a7aadc2258cb64185caac to your computer and use it in GitHub Desktop.
Code Signal - Decipher
This file contains hidden or 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
(def decipher | |
(fn [e] | |
(loop [s e | |
r []] | |
(if (= (count s) 0) | |
(apply str (map #(char (read-string (apply str %)))r)) | |
(let [l (if (= \1 (first s)) 3 2) | |
v (vec s)] | |
(recur (subvec v l) | |
(conj r (take l v)))))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment