| Bytes | Lang | Time | Link |
|---|---|---|---|
| 027 | AWK | 250729T152729Z | xrs |
| 007 | Uiua | 241123T191747Z | ErikDaPa |
| 014 | HP‑41C series | 241123T063007Z | Kai Burg |
| 004 | MATL | 171128T102513Z | Stewie G |
| 018 | PowerShell | 181227T153752Z | GMills |
| 017 | Powershell 6 | 181227T194128Z | mazzy |
| 002 | Japt | 180512T072243Z | Shaggy |
| 050 | brainfuck | 171128T060927Z | Jo King |
| 031 | Tcl | 180410T173302Z | sergiol |
| 010 | Hexagony | 180320T134949Z | Adyrem |
| 016 | FORTH 16 BYTES | 180320T132021Z | panicmor |
| 030 | Fortran GFortran | 180320T131057Z | rafa1111 |
| 011 | Haskell | 180320T110044Z | Laikoni |
| 015 | Java 8 | 180320T103210Z | Kevin Cr |
| 038 | Haskell | 140219T193629Z | Christop |
| 020 | Perl | 120919T063328Z | kSiR |
| 006 | Befunge93 | 171128T055735Z | Jo King |
| 107 | Brainfuck | 120918T005732Z | dspyz |
| 018 | SmileBASIC | 180317T005638Z | 12Me21 |
| 003 | Pyth 3 Bytes | 171128T161002Z | Tornado5 |
| 004 | Husk | 180317T000656Z | Sophia L |
| 003 | Jelly | 180316T221052Z | caird co |
| 006 | Ly | 180316T215027Z | weatherm |
| 017 | PHP | 171128T081458Z | Titus |
| 066 | BrainFuck | 171128T041440Z | l4m2 |
| 034 | TIBasic | 171128T024059Z | Timtech |
| 009 | Python 2 | 120914T172654Z | Matt |
| 030 | Tcl | 171128T022408Z | sergiol |
| 087 | C# | 140219T211938Z | RobIII |
| nan | C# 4 | 140219T192804Z | PauloHDS |
| 014 | Classic ASP | 140219T192008Z | Toothbru |
| 007 | GolfScript | 120917T231843Z | anon |
| 025 | Javascript | 120918T203239Z | Clyde Lo |
| 442 | PHP | 120918T203228Z | scleaver |
| 011 | R | 120915T061528Z | Paolo |
| 004 | APL | 120915T011333Z | marinus |
| 006 | DC | 120914T230533Z | daniero |
| 007 | J | 120914T082713Z | Gareth |
| 006 | Burlesque | 120914T071728Z | mroman |
| 010 | Ruby 1.9 | 120914T035542Z | Paul Pre |
| 007 | q/k | 120914T030625Z | skeevey |
Uiua, 7 bytes
+@@⋕&sc
Explanation:
+@@⋕&sc
&sc => user input
⋕ => parse as number
+@@ => add 64 and convert to corresponding ascii character (@ = 64)
HP‑41C series, 14 Bytes
The alphanumeric liquid crystal display of the HP‑41C pocket calculators can display all modern English alphabet capital letters and a couple lower‐case letters as well.
Clear the contents of the α‑register (CLα), place the number on top of the stack (the X register) and XEQ (execute) the program:
01♦LBL⸆Z 5 Bytes global label requires 4 + n Bytes
02 64 2 Bytes Y ≔ X; X ≔ 64
03 + 1 Byte X ≔ X + 64
04 XTOA 2 Bytes turn value into character and append to α‑register
05 AVIEW 1 Byte display (and perhaps print) contents of α‑register
06 END 3 Bytes terminate program execution
The HP‑41C uses a coded character set that is largely identical to ASCII (but not entirely).
The capital letter A has the numeric value 65.
For 1‑based indexing we add 64 to the given value.
MATL, 4 bytes
64+c
Because, why not. Takes input implicitly, pushes 64 and adds it to the input number. Finally it converts the number to its ASCII-equivalent using c.
PowerShell, 19 18 bytes
-1 byte thanks to @mazzy lolI don't think it'll get much shorter than this.
[char](64+"$args")
Takes input from a command line argument.
Powershell 6, 17 bytes
('@'..'Z')[$args]
brainfuck, 64 56 50 bytes
Thanks to Dorian for saving 3 bytes and inspiring 3 more
,>,[<+[-<+>[-<]>>]<[<++<-]>++>>]<<+++[->+++++<]>+.
How it works
,>, Gets input
[ if a two digit number
<+[-<+>[-<]>>] Gets modulo 2 of first number plus 1
<[<++<-] Sets the fives cell to 2 if the first number is a 2
>++ Adds another 2 to the fives cell
>>] Moves to cell after ones cell
<<+++ Adds 3 to fives cell
[->+++++<] Multiply the fives cell by 5 and add it to the ones cell
>+. Add one and print
Hexagony, 10 Bytes
A({/'+;?/@
Expanded:
A ( {
/ ' + ;
? / @ . .
. . . .
. . .
This honestly took me way longer than it should have, as it's just 2 simple reflections.
The simplest version for this problem is only 2 bytes longer
A ( {
. . . .
? ' + ; @
. . . .
. . .
FORTH 16 BYTES
: n 64 + EMIT ;
OUTPUT:
8 N
8 N H ok
5 N
5 N E ok
12 N
12 N L ok
12 N
12 N L ok
15 N
15 N O ok
23 N
23 N W ok
15 N
15 N O ok
18 N
18 N R ok
12 N
12 N L ok
4 N
4 N D ok
Haskell, 11 bytes
(['@'..]!!)
Try it online! This anonymous function indexes into the string "@ABCDEFG ...".
Java 8, 15 bytes (as lambda function)
n->(char)(n+64)
Java 8, 84 bytes (as full program)
interface M{static void main(String[]a){System.out.printf("%c",new Byte(a[0])+64);}}
Haskell, 38 bytes
main = putChar $ ('a':['a'..'z']) !! c
Where c is the number.
Perl, 20 characters
chr(($ARGV[0] + 64))
Verification :
risk@skynet:~/perl$ for x in {1..26}; do perl ./ord.pl $x; done;
ABCDEFGHIJKLMNOPQRSTUVWXYZrisk@skynet:~/perl$
Befunge-93, 7 6 bytes
"&++,@
Takes advantage of the extra spaces at the end of a wrapping string literal by adding two spaces (32*2 = 64) to the inputted number to turn it into the corresponding alphabetic character. Funnily enough, if we use a implementation that doesn’t include the wrapping spaces, we can do "&+.@ to add the @ (64) to the number instead.
Brainfuck, 107 bytes
>,----------[>++++++[-<------>],----------]<[<]>>[<--[->++++++++++<]>>]+++++++[-<+++++++++>]<-.>++++++++++.
SmileBASIC, 18 bytes
INPUT N?CHR$(N+64)
Pyth - 5 3 Bytes
@Gt
Saved two bytes thanks to ovs
Completely forgot about t and implicit Q
Explanation:
@ Index
G in alphabet of
t one less than
Q Input (implicitly added to solve arity)
Husk, 4 bytes
c+64
Boring, but probably optimal. Adds 64 to the given number and converts it to ASCII. !¡→'A is cuter (awww, the exclamation marks are friends!) but one byte longer.
PHP, 17 bytes
<?=chr(64+$argn);
Run s pipe with -F
BrainFuck, 66
,>,----------[<[->++++++++++<]++++++[>+++++++<-]>>]++++[<++++>-]<.
TI-Basic, 34 bytes
sub("ABCDEFGHIJKLMNOPQRSTUVWXYZ",Ans,1
This is as short as it gets...
Python 2, 9 bytes
chr(64+x)
Or, reading from stdin and printing to stdout: 21
print chr(64+input())
C#, 87
class P{static void Main(string[]a){System.Console.Write((char)(int.Parse(a[0])+64));}}
Complete program (not some (part of a) "function" expecting foo to be bar to work), accepts command line parameter: foo.exe 1 prints A, foo.exe 16 prints P
C#, 10
When I make the same assumptions as, for example, the 'code-golfers' that posted the VSCript Classic ASP, Python, Burlesque, Ruby, C solutions we can get it down to 10:
(char)x+64
"Assuming x is magically initialized / passed in / on the stack / whatever excuse" and the contest doesn't explicitly require me to print it, just "return" it (which most of the above solutions don't do, either).
C# 4,50KB (196 characters)
My first time here =)
using System; namespace W { class P { static void Main(string[] args) {
Console.WriteLine(" abcdefghijklmnopqrstuvwxyz".ToCharArray()[int.Parse(Console.ReadLine())]);
}
}
}
Classic ASP (14 bytes):
<%=Chr(c+64)%>
Expects c to hold the character number.
GolfScript, 7
64+]''+
Commentary
64 # corresponds to '@' in ASCII (65 is 'A')
+] # add the input to 64. ']' is used for ASCII.
''+ # the conversion process
Javascript, 25 chars
String.fromCharCode(66-x);
PHP, 22 chars
echo chr(66-$argv[0])
PHP 442
$alphabet = Array('A' => 1,'B' => 2,'C' => 3,'D' => 4,'E' => 5,'F' => 6,'G' => 7,'H' => 8,
'I' => 9,'J' => 10,'K' => 11,'L' => 12,'M' => 13,'N' => 14,'O' => 15,'P' => 16,'Q' => 17,
'R' => 18,'S' => 19,'T' => 20,'U' => 21,'V' => 22,'W' => 23,'X' => 24,'Y' => 25,'Z' => 26
)
function testInputForAlphabetCharacter($input){
for($index = 0; $index < count($alphabet); $i = $i + 1){
if($alphabet[$index] == $input){
echo($index);
}
}
}
$input = $_GET['input'];
testInputForAlphabetCharacter($input);
R, 11 characters
LETTERS[x]
Usage:
LETTERS[21]
[1] "U"
APL (4)
(Full program)
⎕⌷⎕A
Explanation:
⎕ (user input) ⌷ (index) ⎕A (alphabet)
(They're supposed to be boxes, it's not an encoding problem.)
DC - 6 characters
Full program including input and output.
?64+af
save to file and run with $ dc file
J, 7 characters
a.{~64+
Usage:
a.{~64+1
A
Burlesque (6 characters)
Assuming the number is already on the stack:
64.+L[(see here in action.).
Does the usual: Add 64, convert to character based on ASCII value.
If number is supplied as a string via stdin to stdout (10 characters):
ri64.+L[sh
Alternative version without using ASCII value conversion:
'@'Zr@\/!!
Ruby 1.9 (10)
(x+64).chr
Reading from STDIN and printing to STDOUT:
$><<(gets.to_i+64).chr
q/k (7)
As partially applied composition:
10h$64+