Skip to content

Instantly share code, notes, and snippets.

@defHLT
Created January 9, 2015 14:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save defHLT/5305911462431b0976c3 to your computer and use it in GitHub Desktop.
Save defHLT/5305911462431b0976c3 to your computer and use it in GitHub Desktop.
#!/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