Skip to content

Instantly share code, notes, and snippets.

@mnzk
Created October 26, 2011 14:43
Show Gist options
  • Save mnzk/1316549 to your computer and use it in GitHub Desktop.
Save mnzk/1316549 to your computer and use it in GitHub Desktop.
Excel A1 Converter 2
(defn N->A [n]
(let [za "0ABCDEFGHIJKLMNOPQRSTUVWXYZ"
alen (dec (count za))
iter (fn [[n xs]] [(int (/ n alen))
(cons (nth za (rem n alen)), xs)])]
(->> (iterate iter [n '()])
(drop-while (comp not zero? first))
first second
(apply str))))
(N->A 10000000000) ;=> "AFIPYQJP"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment