17
1
In Excel, the columns range from A-Z, AA,AB,AZ,BA,..,BZ
and so on. They actually each stand for numbers, but rather are encoded as alphabet strings.
In this challenge, you will be given a string of alphabets, and you must calculate the column it corresponds to.
Some tests:
'A' returns 1 (meaning that it is the first column)
'B' returns 2
'Z' returns 26
'AA' returns 27
'AB' returns 28
'AZ' returns 52
'ZZ' returns 702
'AAA' returns 703
You can assume that capital letters will be given only.
Shortest bytes win.
Good luck!
So... base 26 with the alphabet? – Jo King – 2018-10-20T01:55:29.947
1It isn't quite base 26 because there's no zero. – J.Doe – 2018-10-20T02:03:56.010
@J.Doe Ah, I guess you're right. I didn't notice since my solution automatically treated
Z
as 10 anyway – Jo King – 2018-10-20T02:56:22.710Reverse challenge. – user202729 – 2018-10-20T03:01:31.730
6
@JoKing Bijective base.
– user202729 – 2018-10-20T03:03:01.650I wonder if someone will come up with a solution in Excel. – Titus – 2018-10-20T04:46:42.477
Can we take input as an array/list of characters? – Shaggy – 2018-10-20T11:14:04.797
@Titus I don't have Excel or know it... but isn't there a
COLUMN
function that would do this? – Quintec – 2018-10-20T23:03:51.237