Given a string, calculate the number of the column it corresponds to

Perl 6, 17 bytes

{:26[.ords X-64]}

Try it online!

Anonymous code block that subtracts 64 from each byte value and converts from base 26 with Z overflowing to the next column.


Google Sheets, 21 bytes

(formula evaluates to the result, takes input from cell A1)

=column(indirect(A1&2

R, 48 43 bytes

-5 bytes thanks to @Giuseppe, using the same logic, but as a program that eliminates the nchar call.

for(i in utf8ToInt(scan(,"")))F=F*26+i-64;F

Try it online!

Tags:

Math

Code Golf