Code Golf: Numeric Equivalent of an Excel Column-Name
Posted
by Vivin Paliath
on Stack Overflow
See other posts from Stack Overflow
or by Vivin Paliath
Published on 2010-04-14T02:06:45Z
Indexed on
2010/04/14
2:13 UTC
Read the original article
Hit count: 481
Can you figure out the numeric equivalent of an Excel column string in the shortest-possible way, using your favorite language? For example, the A
column is 1, B
is 2, so on and so forth. Once you hit Z
, the next column becomes AA
, then AB
and so on.
Rules:
Here is some sample input and output:
A: 1
B: 2
AD: 30
ABC: 731
WTF: 16074
ROFL: 326676
I don't know if the submitter is allowed to post a solution, but I have a Perl solution that clocks in at 125 characters :).
© Stack Overflow or respective owner