Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Speedy category for Excel Column Number by dlinford
def column_number(name: str) -> int:
alphabet_dict = {chr(i): i-64 for i in range(65, 91)}
translation = alphabet_dict[name[len(name)-1]]
for i in range(1, len(name)):
translation += alphabet_dict[name[len(name)-i-1]]*26**i
return translation
print("Example:")
print(column_number("AA"))
# These "asserts" are used for self-checking
assert column_number("A") == 1
assert column_number("Z") == 26
assert column_number("AB") == 28
assert column_number("ZY") == 701
assert column_number('FXSHRXW') == 2147483647
print("The first mission is done! Click 'Check' to earn cool rewards!")
Feb. 7, 2023