31
\$\begingroup\$

Challenge

In this challenge you have to take a number as input and output the corresponding letter of the alphabet, and vice versa. (1 <=> A, 2 <=> B) etc.

1 -> A 2 -> B ... 26 -> Z A -> 1 B -> 2 ... Z -> 26 

Rules

  • This is , so shortest code in bytes wins.
  • The input will only consist of either an uppercase letter from A to Z or an integer from 1 to 26 inclusive.
  • Trailing whitespaces (space and newline) are allowed.
\$\endgroup\$
15
  • 1
    \$\begingroup\$ Why duplicate? O.o It is not equal. \$\endgroup\$ Commented Aug 15, 2016 at 21:50
  • 3
    \$\begingroup\$ Welcome to Programming Puzzles and Code Golf! This challenge could use a bit of clarification. For example, you could specify what inputs we would need to handle, since there are invalid inputs. I recommend posting future challenges to the Sandbox where they can get meaningful feedback before being posted to the main site. \$\endgroup\$ Commented Aug 15, 2016 at 21:55
  • 2
    \$\begingroup\$ Will we receive 26 as an integer or "26" as a string, or are both allowed? \$\endgroup\$ Commented Aug 15, 2016 at 22:38
  • 2
    \$\begingroup\$ Does it have to be uppercase, or is lowercase acceptable instead? \$\endgroup\$ Commented Aug 16, 2016 at 1:45
  • 1
    \$\begingroup\$ Seriously, another alphabet challenge? ( ͡° ͜ʖ ͡°) \$\endgroup\$ Commented Aug 16, 2016 at 7:11

61 Answers 61

1 2
3
0
\$\begingroup\$

AWK, 46 bytes

@load"ordchr" $0=/[A-Z]/?ord($0)-64:chr($0+64) 

Attempt This Online!

\$\endgroup\$
1 2
3

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.