Prev: Writing to same file from several kernels?
Next: Displaying a list of variables together with their names
From: Matthias Bode on 23 Jul 2010 07:13 Hola: CharacterRange["A","B"]//ColumnForm A B Is it that what you meant? MATTHIAS BODE COCHABAMBA/BOLIVIA > Date: Thu, 22 Jul 2010 05:39:56 -0400 > From: cmpbrn(a)gmail.com > Subject: Strange 26base enumeration > To: mathgroup(a)smc.vnet.net > > I need an algorithm to get such a table: > > A > B
From: dr DanW on 23 Jul 2010 07:15 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
First
|
Prev
|
Pages: 1 2 Prev: Writing to same file from several kernels? Next: Displaying a list of variables together with their names |