| Bytes | Lang | Time | Link |
|---|---|---|---|
| nan | Pxem | 240621T033727Z | 鳴神裁四点一号 |
| 058 | PHP | 240620T172523Z | int 21h |
| 009 | Uiua | 231022T054847Z | chunes |
| 110 | Rust | 231022T130855Z | leo848 |
| 007 | Thunno 2 | 230713T173754Z | The Thon |
| 2017 | x8616 machine code | 221011T124753Z | 640KB |
| 045 | Arturo | 221109T182929Z | chunes |
| nan | 221225T102827Z | RARE Kpo | |
| 026 | POSIX Shell Command Language + Utilities | 221122T190125Z | набиячлэ |
| 048 | Julia | 221007T181538Z | Ashlin H |
| 018 | k | 221116T095952Z | cillianr |
| 016 | ><> | 221109T074855Z | Emigna |
| 012 | Pyth | 221008T061218Z | u-ndefin |
| 061 | Excel ms365 | 221007T121629Z | JvdV |
| 041 | Elixir | 221011T093205Z | Kirill L |
| 028 | Ruby nl | 221011T075858Z | Kirill L |
| 043 | C# | 221010T074153Z | Acer |
| 137 | C++ gcc | 221009T183211Z | huanglx |
| 041 | Knight v2 | 221009T190731Z | naffetS |
| nan | Fig | 221009T185529Z | naffetS |
| 019 | Thon | 221007T121722Z | The Thon |
| 029 | J | 221009T161353Z | huanglx |
| 067 | Rust | 221009T123414Z | corvus_1 |
| 041 | Python | 221007T213136Z | Jonathan |
| 015 | Jelly | 221008T192645Z | sporkl |
| 031 | Raku | 221008T154858Z | Sean |
| 013 | K ngn/k | 221008T135334Z | coltim |
| 050 | Red | 221008T100250Z | chunes |
| 061 | C clang | 221007T120038Z | pavi2410 |
| 048 | JavaScript ES6 | 221007T121715Z | Arnauld |
| 062 | Red | 221008T075422Z | Galen Iv |
| 009 | Pyth | 221008T061223Z | hakr14 |
| 025 | Ly | 221008T055413Z | cnamejj |
| 029 | Factor | 221007T114427Z | Razetime |
| 021 | Retina 0.8.2 | 221007T125356Z | Neil |
| 024 | Perl 5 plF | 221007T210015Z | Xcali |
| 042 | sed | 221007T193726Z | Jiří |
| 038 | R | 221007T184800Z | pajonk |
| 064 | brainfuck | 221007T183018Z | m90 |
| 034 | Juby | 221007T181151Z | Jordan |
| 015 | BQN | 221007T155926Z | Dominic |
| 037 | Ruby | 221007T125340Z | Jordan |
| 510 | Nibbles | 221007T125310Z | Dominic |
| 039 | PowerShell | 221007T153845Z | user3141 |
| 018 | Pyth | 221007T125750Z | Manish K |
| 011 | 05AB1E | 221007T121926Z | Kevin Cr |
| 013 | Charcoal | 221007T125808Z | Neil |
| 012 | MathGolf | 221007T124941Z | Kevin Cr |
| 044 | Python | 221007T124509Z | loopy wa |
| 066 | simply 0.11 | 221007T122726Z | Ismael M |
| 008 | Vyxal | 221007T113922Z | lyxal |
| 050 | Python 3 | 221007T112709Z | The Thon |
| 009 | Japt | 221007T112000Z | Shaggy |
| 013 | APL Dyalog Extended | 221007T111715Z | Adá |
Pxem, 0 + 45 = 45 bytes
Filename, with non ascii byte. For example \5 is U+0005.
\5.t.w.i1.-a.+.m\1.-.t.m.a.cj.x.s.vA.v.cj.a.v.p
How it works
\5.t register = 5
.w while pop() != 0
.i push getchar() # eof is -1
1.-a.+ push(97+abs(pop()-49))
.m\1.-.t register -= 1
.m push register
.a endwhile
.cj.x while top > 106
.s drop
.vA.v insert 65 to bottom of stack
.cj.a endwhile
.v.p putchar() from bottom to top
PHP, 58 bytes
fn($x)=>strtr(sprintf("%05d",$x),1234567890,"abcdefghiA");
The solution is based on the characters translation. sprintf fills the string with the trailing zeroes which are get translated to "A" while the digits 123456789 are converted to abcdefghi.
Uiua, 11 10 9 bytes
⬚@A↙¯5+@`
- -1 byte from Dominic van Essen
- -1 byte from Bubbler
⬚@A↙¯5+@`
+@` # add backtick character
⬚@A↙¯5 # take the last five characters, filling any excess with A
Rust, 110 bytes
Takes the number and returns the converted string in the aaaaa way.
|x:u64|"A".repeat((4-x.ilog(10))as _)+&x.to_string().bytes().fold(format!(""),|mut s,b|{s.push((48+b)as _);s})
Rust, 93 bytes
Returns a byte slice, i.e. Vec<u8> instead that corresponds to the ASCII-encoded aaaaa string.
|x:u64|{let mut v=vec![65;(4-x.ilog(10))as _];v.extend(x.to_string().bytes().map(|b|48+b));v}
Thunno 2, 7 bytes
ÄLJ'A5ṙ
Explanation
ÄLJ'A5ṙ '# Implicit input
Ä # Number to alphabet
L # Lowercase each
J # Join into a string
'A '# Using "A" as a filler,
5ṙ # pad the string to length 5
# Implicit output
x86-16 machine code, 20 17 bytes
00000000: fcb8 4141 abab fd03 f14e ac04 30aa e2fa ..AA.....N..0...
00000010: c3
Callable function, custom calling convention. Input string at DS:[SI], CX = input string length (1-5), output string buffer at ES:[DI].
Listing:
FC CLD ; string direction forward
B8 4141 MOV AX, 'AA' ; AL and AH = pad char
AB STOSW ; pad only first 4 chars
AB STOSW
FD STD ; string direction reverse
03 F1 ADD SI, CX ; SI = end of input string
4E DEC SI ; SI = last char of input
A_LOOP:
AC LODSB ; load next char
04 30 ADD AL, 'a'-'1' ; aaaaaa convert
AA STOSB ; write to output
E2 FA LOOP A_LOOP
C3 RET ; return to caller
Test program output:
Props: -3 bytes thx to @l4m2!
ultra verbose awk solution:
echo '43213
8645
342
99991' |
awk '$!NF=sprintf("%c%c%c%c%c",___+(__+$(_=($(_<_)=sprintf("%.*d%s",5-NF, _=_<_,$_))^_))^!!$_,___+(__+$++_)^!!$_,(__+$++_)^!!$_+___, ___+(__+$++_)^!!$_,___+(__+$++_)^!!$_)' __=32 ___=64 FS=
dcbac
Ahfde
AAcdb
iiiia
POSIX Shell Command Language + Utilities, 26 bytes
printf %05d $1|tr 0-9 Aa-i
Self-explanatory: printf renders the argument padded to five columns with zeroes, then tr does the transformation per spec.
Transcript of test cases:
$ cat a.sh; echo; wc -c a.sh
printf %05d $1|tr 0-9 Aa-i
26 a.sh
$ ./a.sh 8645; echo
Ahfde
$ ./a.sh 43213; echo
dcbac
$ ./a.sh 8645; echo
Ahfde
$ ./a.sh 342; echo
AAcdb
$ ./a.sh 99991; echo
iiiia
Julia, 48 bytes
~x=replace(lpad(x,5,'A'),('1':'9'.=>'a':'i')...)
Julia 1.0, 67 65 bytes
~x=getindex.([Dict(0:9 .=>['A';'a':'i'])],[0;0;0;0;x][end-4:end])
-2 bytes thanks to @MarcMush: replace [[0,0,0,0];x] with [0;0;0;0;x]
- Function is defined with the unary operater
~ - The dictionary is wrapped in an array to allow passing multiple values.
- For padding, I concatenate a zero array and the input array. Only the last five elements
[end-4:end]are used.
k, 18 bytes
"A"^-5$10h$96+10\:
><>, 17 16 bytes
r5l6=.a7+!
68*+o
Explanation
r ! # reverse stack on first iteration
5l6=. # if stack length is 5, move to next row
a7+ # else add 17 to stack
68*+o # add 48 to each item on stack and print as char
Pyth, 14 13 12 bytes
@L+\AG+mZ-5l
Explanation:
@L+\AG+mZ-5l # whole program
# implicit output
L # left map with lambda d:
@ # using index
+ # concatenate
\A # literal "A"
G # and literal "abc...xyz"
+ # into a concatenation of:
mZ # a constructed list of n zeroes
# where n is: (the 2nd argument for m is supplied an int)
-5 # the difference of 5
l # and the length of implicit input (Q)
# and the implicit input (Q)
Excel (ms365), 63 61 bytes
-2 Thanks to @EngineerToast for 61 bytes:
=RIGHT(CONCAT("AAAA",CHAR(96+MID(A1,SEQUENCE(LEN(A1)),1))),5)
Or, the original answer for 63 bytes:
=CONCAT(MID("Aabcdefghi",MID(TEXT(A1,"00000"),ROW(1:5),1)+1,1))
Note that it can probably be done with less bytes if input is an array of numbers but thought I'd take a single integer as startpoint.
C#, 43 bytes
x=>x.PadLeft(5,'').Select(y=>(char)(y+48))
represents the character with code 17; 48 is added to this to produce A.
C++ (gcc), 142 138 137 bytes
-4 thanks to @ceilingcat.
First time golfing in C++, there are probably many places where improvements could be made. #include <bits/stdc++.h> was really expensive in terms of bytes.
#include<bits/stdc++.h>
int f(int n){for(int i=5;i--;){putchar(((n%(int)exp10(i+1))/(int)exp10(i))?(n%(int)exp10(i+1))/exp10(i)+96:65);}}
Takes integer inputs and outputs as string.
Thon, 19 bytes
n"Aabcdefghi"b5"A"J
Input as a number (e.g. 824). Output as a string (e.g. AAhbd).
Explanation
n"Aabcdefghi"b5"A"J
n // Input a number
"Aabcdefghi" // Push the string of letters
b // Convert the number to Base-"Aabcdefghi" (see below)
5"A"J // Fill with "A" up to 5 characters
// (implicit output)
Converting to base-"Aabcdefghi" is a trick to replace every "1" with "a", every "2" with "b", etc.
Thon (Symbols), 16 bytes
(Note: this language is newer than the challenge)
)ş{í1-å`;}""]5AṚ
Explanation
)ş{í1-å`;}""]5AṚ
) // Create an empty list
ş // Get input as a string
{ } // For each character in the input:
í // Convert to an integer
1- // Subtract 1
å` // Push the lowercase alphabet and get the character
; // Append to the list
""] // Join the list by an empty string
5AṚ // Fill the string with "A" up to 5 characters
// (implicit output)
J, 29 bytes
There probably is a shorter way (perhaps with a.) than a hard-coded string mapping, but everything I tried ended up being longer.
'Aabcdefghi'{~],~[:0"0[:i.5-#
Takes input as array of numbers and outputs a string.
Python, 42 41 bytes
-1 thanks to loopy walt's suggestion to use XOR, ^, instead of addition.
lambda a:[chr(96^d)for d in[33]*5+a][-5:]
An unnamed function that accepts a list of integers from \$[1,9]\$ and returns a list of characters.
Jelly, 15 bytes
DịØa;@”Ax5¤Uḣ5U
Almost certainly I'm missing some atoms or syntax tricks that can get this down further. 11 bytes are spent to handle the padding.
Explanation:
DịØa;@”Ax5¤Uḣ5U
D get decimal representation
ịØa index into lowercase alphabet
”Ax5¤ repeat "A" 5 times
;@ prepend "A"s to the other string
Uḣ5U take the last 5 characters
Raku, 31 bytes
{TR/0..9/Aa..i/}o*.fmt('%05d')
*.fmt('%05d') is an anonymous function that formats its integer argument to five digits, padded on the left with zeroes. { TR/0..9/Aa..i/ } is a second anonymous function that transliterates its string argument, turning 0 into A and 1-9 into a-i. The o operator composes those two functions.
K (ngn/k), 13 bytes
"A"^-5$`c$96+
`c$96+convert input of digits to corresponding letters-5$left-pad to length 5 with spaces"A"^fill spaces with "A" (and implicitly return)
Red, 50 bytes
func[v][insert/dup v 17 5 take/last/part v + 48 5]
Takes input as a vector of code points and returns output as the same.
insert/dup v 17 5Insert five 17s at the beginningv + 48Add 48 to each elementtake/last/part v 5Take the last five elements
C (clang), 69 67 63 61 bytes
f(x,o,i)char*o;{for(memset(o,65,i=5);x;x/=10)o[--i]=x%10+96;}
- thanks to @ceilingcat for saving 4+2 bytes
JavaScript (ES6), 48 bytes
Expects an integer and returns a string.
f=(n,k=5)=>k?f(n/10|0,k-1)+"Aabcdefghi"[n%10]:''
C (gcc), 48 bytes
k;f(n){k++>4?k=0:f(n/10)|putchar(n?n%10+96:65);}
47 bytes
This version was suggested by @jdt.
i;f(*o,x){for(i=5;i;x/=10)o[--i]=x?96+x%10:65;}
Pyth, 9 bytes
.[\A5m@Gt
This answer uses a sufficiently different approach from the existing Pyth answer(s).
Explanation:
.[\A5m@Gt | Full code
.[\A5m@GtdQ | with implicit variables
------------+----------------------------------------------------
m Q | Replace each number d in the input with
@G | the character of the lowercase alphabet with index
td | d minus 1
.[\A5 | Pad the array on the left with A to a length of 5
Ly, 25 bytes
iry5L[f5f-['Ao,]]pp['0+o]
Pretty straight forward reading of the rules...
ir - read the digits in a codepoints, reverse stack
y5 - push digit count, push "5"
L - check: digitCount<5
[ ]pp - exec block if digit count < 5
f5f- - subtract digit count from 5, get pad count
[ ,] - loop once for each pad digit...
'Ao - print "A"
[ ] - loop or all the codepoints on the stack
'0+ - convert from 0-9 to a-i
o - print as character
Retina 0.8.2, 21 bytes
T`d`_l
^
AAAA
!`.{5}$
Try it online! Link includes test cases. Explanation:
T`d`_l
Translate digits to lowercase letters.
^
AAAA
Prefix four As.
!`.{5}$
Take the last 5 letters.
A port of @Jiří's sed answer is also 21 bytes:
T`d`_l
+`^.{0,4}$
A$&
Try it online! Link includes test cases.
R, 38 bytes
\(d)intToUtf8(tail(c(!1:5,d+31),5)+65)
Takes input as a vector of digits, outputs a string.
brainfuck, 64 bytes
>>>>>+>,[>,]<<<<<<-[---[----<+>]<++.>>-]>[<-[----->+<]>---.[-]>]
Explanation
>>>>>+>
Move to position 5, make the value there 1, and move to position 6.
,[>,]
Read the digits into consecutive positions from there onward.
<<<<<<
Move 6 positions to the left. From here, each 0 before the 1 in position 5 indicates an A to be output.
-[---[----<+>]<++.>>-]
Subtract 1. Loop while it's not 0 (thus was not 1):
- Subtract 3 more, making −4.
- Loop subtracting 4 and adding 1 to the left, producing (256-4)/4=63 in the cell to the left.
- Move left, add 2 more for 65, and output that (
A). - Move right twice, for a net movement of 1 to the right, and subtract 1 (and repeat).
>[<-[----->+<]>---.[-]>]
Move right. Loop while it's not 0 (over all the digits):
- Move left and subtract 1, making −1.
- Loop subtracting 5 and adding 1 to the right, adding (256-1)/5=51 to the digit's character code.
- Move right and subtract 3, for a net +48 to the digit's character code. 48 is the difference between
1anda, and likewise for the other digits (as both digits and letters are contiguous in ASCII). - Output the letter produced from the digit.
- Zero that position (as it will be reused in the next iteration) and move right (and repeat).
J-uby, 34 bytes
I think I’m finally starting to get the hang of J-uby. A few bytes shorter than my Ruby answer.
:*&(:+&96|:chr)|:join|~:rjust&?A&5
BQN, 17 15 bytes
Edit: -2 bytes thanks to Razetime
¯5↑"AAAA"∾+⟜'`'
+⟜'`' # add each element of input to the '`' character
∾ # join this to
"AAAA" # "AAAA" (shorter than (5⥊'A'))
_5↑ # take -5 elements
# (which takes 5 elements from the end)
Nibbles, 5 bytes (10 nibbles)
&"A"5+'`'
+ # add each element of input
'`' # to '`' character
& # then justify the text
"A" # using the "A" character
5 # to a width of 5
PowerShell, 39 bytes
-join($args|%{[char](96+$_)})|% *ft 5 A
Takes integers as unnamed arguments. Nothing fancy, just adds 96 to get to the ASCII code of 'a', casts to a char, joins the chars to a string, then pipes the string to % (an alias for ForEach-Object), which will call the string's member "PadLeft". Output is implicit.
Pyth, 18 bytes
V-5lzp"A")Vzp@GtsN
Explanation
V-5lzp"A")Vzp@GtsN
V # For loop with N as variable
z # Input
l # Length
-5lz # Subtract length of input from 5
p"A" # Prints "A"
) # End of for loop
p # Print without any additional newline
G # Initialized to "abcdefghijklmnopqrstuvwxyz"
sN # Cast N to an integer
t # Subtract 1
@ # Get element at index
05AB1E, 11 bytes
₃+>çΔ'Aš5.£
Input as a list of digits; output as a list of characters.
(If the inputs would have been 0-based (digits 0-9 mapping to a-j) instead of 1-based, the > could have been dropped.)
Try it online or verify all test cases.
Or alternatively:
5j9LðšA¬uì‡
Both input and output as a string.
Try it online or verify all test cases.
Explanation:
Unfortunately 05AB1E lacks a left-pad up to length builtin (unless by spaces), so most of the bytes are to account for that in the first program..
₃+> # Add 96 to each value
ç # Convert each from a codepoint-integer to a character
Δ # Loop until the result no longer changes:
'Aš '# Prepend an "A"
5.£ # Leave (up to) the last 5 characters from the list
# (after which the result is output implicitly)
5j # Left-pad the (implicit) input-string with spaces up to length 5
9L # Push list [1,2,3,4,5,6,7,8,9]
ðš # Prepend a space: [" ",1,2,3,4,5,6,7,8,9]
A # Push the lowercase alphabet: "abcdefghijklmnopqrstuvwxyz"
¬ # Push its first character (without popping): "a"
u # Uppercase it: "A"
ì # Prepend it: "Aabcdefghijklmnopqrstuvwxyz"
‡ # Transliterate the space-padded input from [" ",1,2,3,4,5,6,7,8,9] to
# "Aabcdefghij..."
# (after which the result is output implicitly)
Charcoal, 13 bytes
✂⁺×⁴A⭆S§β⊖ι±⁵
Try it online! Link is to verbose version of code. Explanation:
A Literal string `A`
× Repeated
⁴ Literal integer `4`
⁺ Concatenated to
S Input as a string
⭆ Map over digits
β Predefined variable lowercase alphabet
§ Indexed by
ι Current digit
⊖ Decremented
✂ Sliced from
⁵ Literal integer `5`
± Negated
MathGolf, 12 bytes
(h5,'A*\É▄\§
Input as a list of digits; output as string.
Or alternatively:
▄▒\(§y♫α'A═╡
Input as a list of digits; output as a string wrapped inside a list.
Explanation:
( # Decrease each digit in the (implicit) input-list by 1
# (because MathGolf uses 0-based indexing)
h # Push the length of the list (without popping)
5, # Calculate 5-length
'A* '# Repeat "A" that many times
\ # Swap so the list as at the top again
É # For-each over the digits, using 3 characters as inner code-block:
▄ # Push the lowercase alphabet
\ # Swap so the current digit is at the top
§ # Index the digit into the alphabet
# (after which the entire stack joined together is output implicitly as result)
▄ # Push the lowercase alphabet
▒ # Convert it to a list of characters
\ # Swap so the (implicit) input-list is at the top
( # Decrease each digit by 1 (because MathGolf uses 0-based indexing)
§ # Index each digit in the list into the alphabet list
y # Join it back together again
♫ # Push 10000
α # Pair it with the earlier string
'A═ '# Pad both to an equal length by left-padding with "A"
╡ # Remove the last item from the pair (the 10000)
# (after which the entire stack joined together is output implicitly as result)
Python, 44 bytes
lambda s:f"{s:05}".translate("bcdefghiAa"*9)
Takes an integer and returns a string.
simply 0.11, 66 bytes
This abuses bugs in the parser, to save bytes.
It works with the commit 98783927a8a232b8e0afb46f380e02348b0f7cbb - current commit at the time.
The behaviour will, VERY LIKELY, change in the future.
Creates an anonymous function that receives an array of numbers, and outputs the value.
fn($L){if$l=&len($L)<5for$_ in$l..4out'A'each$L as$i;out!ABCL[$i]}
Example of usage:
This should output "AAfcf".
$fn = fn($L){if$l=&len($L)<5for$_ in$l..4out'A'each$L as$i;out!ABCL[$i]}
call $fn([5,2,5]);
How it works?
It simply checks the length of the array, and if it is lower than 5, it outputs 1 to 5 'A's.
It goes from 0 to 4 because it uses a range operator.
Going from 4 to 4, is just 1 iteration - the number 4 itself.
Going from 0 to 4, is 5 iterations - the number 0, number 1, number 2, number 3 and number 4.
Then, it uses the pre-existing constant !ABCL, which contains the letters from a to z, in lowercase.
The values in the array are used as indexes into the constant.
Ungolfed
Very code-y looking:
$fn = fn($list) => {
$len = &len($list);
if $len < 5 then {
for $_ in $len..4 {
echo 'A';
}
}
foreach $list as $index {
echo !ABCL[$index];
}
};
Pseudo-code looking:
Set $fn to an anonymous function($list)
Begin.
Set $len to the result of calling &len($list).
In case $len < 5 then
Begin.
Loop from $len to 4 as $_
Begin.
Show the value 'A'.
End.
End.
Loop through $list as $index
Begin.
Show the contents of !ABCL[$index].
End.
End.
All versions do the exact same.
Vyxal, 8 bytes
øA∑\A5ø↳
Finally, a use for some of the more niche string digraphs. Takes input as a list of digits, outputs a single string.
Explained
øA∑\A5ø↳
øA # Get the nth letter of the alphabet for each digit in the input
∑ # Join as a single string
\A # Push the string "A" to the stack
5 # Push the number 5 to the stack
ø↳ # And left pad the single string from early with "A"s until it's 5 characters long
Python 3, 50 bytes
lambda l:''.join(chr(96+i)for i in l).rjust(5,'A')
Takes a list of integers as input
Japt, 9 bytes
Takes input as a string.
c+48 ù'A5
c+48 ù'A5 :Implicit input of string
c+48 :Map charcodes, adding 48 to each
ù'A5 :Left pad with "A" to length 5
APL (Dyalog Extended), 13 bytes
Full program prompting for digit number list
'A'@=¯5↑⎕⊇⌊⎕A
⎕A uppercase Alphabet
⌊ Lowercase that
⎕⊇ use the input to select from that (1-indexed)
¯5↑ take the last 5 elements of that, adding padding elements on the left
'A' put "A"s where equal to the padding element


