Created
January 9, 2015 14:32
-
-
Save defHLT/5305911462431b0976c3 to your computer and use it in GitHub Desktop.
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
#!/usr/bin/clojure | |
; Created: Fri Jan 9 16:10:56 EET 2015 | |
; encoding: utf-8 | |
(defn burrows-wheeler [s] | |
(let [size (count s)] | |
(->> | |
(repeat 2 s) | |
(apply str) | |
(partition size 1) | |
(take size) | |
vec | |
(sort-by #(str (first %1))) | |
(map last) | |
(apply str)))) | |
(prn (burrows-wheeler "banana")) ;; "bnnaaa" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment