Created
May 16, 2015 11:39
-
-
Save BrunoBonacci/cb13fc05bd720652eb17 to your computer and use it in GitHub Desktop.
Crypto Square problem
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
(defn crypto-square [s] | |
(->> (re-seq #"\w+" s) | |
(map clojure.string/lower-case) | |
(apply str) | |
(#(let [size (int (Math/ceil (Math/sqrt (count %))))] | |
(partition size size (repeat " ") %))) | |
(apply map vector) | |
(map (partial apply str)) | |
(clojure.string/join "\n"))) | |
(println (crypto-square "If man was meant to stay on the ground god would have given us roots")) | |
;; imtgdvs | |
;; fearwer | |
;; mayoogo | |
;; anouuio | |
;; ntnnlvt | |
;; wttddes | |
;; aohghn | |
;; sseoau |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment