Re: Strange 26base enumeration
- To: mathgroup at smc.vnet.net
- Subject: [mg111215] Re: Strange 26base enumeration
- From: dr DanW <dmaxwarren at gmail.com>
- Date: Fri, 23 Jul 2010 07:15:44 -0400 (EDT)
- References: <i293lk$m1e$1@smc.vnet.net>
Oooo. Nice little morning puzzle to wake my brain up. At first, it looked like an easy solution using IntegerDigits, but ran into a problem that this isn't a true digit system, in that it does not have a zero. I had to add a little logic to deal with that. Try this: ToExcelColumn[n_Integer] := Module[{id}, id = IntegerDigits[n, 26] //. {pre___, d_, 0, post___} :> {pre, d - 1, 26, post} //. {0, post___} :> {post}; StringJoin[id /. Thread[Range[1, 26] -> CharacterRange["A", "Z"]]]]; Map this function onto a range starting at 1 and you will get your table. Enjoy, Daniel