| Bytes | Lang | Time | Link |
|---|---|---|---|
| 1042 | Zsh | 240912T033654Z | roblogic |
| 241 | Vyxal | 240313T211942Z | emanresu |
| 268 | Vyxal 3 | 240819T133955Z | Europe20 |
| nan | 160823T085819Z | Clamburg | |
| 3828 | Pascal | 240312T200018Z | Kai Burg |
| 991 | jq | 240313T204750Z | Sara J |
| 383 | Pip | 160822T040121Z | DLosc |
| 1074 | Perl 5 | 230110T160545Z | Andy A. |
| 3050 | G++ | 181110T184454Z | l4m2 |
| nan | Japt | 220923T103238Z | Shaggy |
| 464 | C# Mono C# Shell | 220926T083804Z | Acer |
| 2073 | C gcc | 220924T171612Z | jdt |
| 268 | MathGolf | 220923T120118Z | Kevin Cr |
| 870 | J | 220922T173655Z | south |
| 489 | Knight | 220921T002413Z | Sampersa |
| nan | Python3 | 190819T075744Z | Steven H |
| 1040 | R | 190819T081606Z | Robin Ry |
| 221 | Reg a.k.a. Unofficial Keg | 190818T142240Z | user8505 |
| nan | Runic Enchantments | 190819T143719Z | Draco18s |
| 618 | Malbolge | 190819T135516Z | Kamila S |
| 285 | Pyth | 190819T103449Z | ar4093 |
| 539 | 33 | 190818T201904Z | TheOnlyM |
| 267 | Pushy | 181208T165617Z | FlipTack |
| 505 | Add++ | 181201T171646Z | caird co |
| 863 | SmileBASIC | 180301T215827Z | 12Me21 |
| 694 | Forth | 170221T195521Z | mbomb007 |
| 530 | Befunge93 | 161202T150622Z | James Ho |
| 1589 | Haskell | 160821T192736Z | Laikoni |
| 285 | Sesos | 161005T174419Z | Erik the |
| nan | ASCII constrained x86 Machine Code for DOS | 160823T002429Z | Michael |
| 572 | GNU sed | 160828T070841Z | seshouma |
| 043 | Deadfish | 160901T001852Z | Destruct |
| nan | Brainfuck | 160821T133043Z | betseg |
| 406 | Jelly noncompetitive | 160828T024142Z | Aly |
| 1224 | Matlab | 160822T165845Z | pajonk |
| 6577 | Java 8 | 160822T160848Z | Copper |
| nan | dc | 160823T160800Z | brhfl |
| nan | FerNANDo | 160823T191300Z | Business |
| 921 | Perl 6 | 160823T074411Z | smls |
| 560 | Reng | 160822T215527Z | Conor O& |
| 712 | Retina | 160822T202350Z | Martin E |
| 455 | Fission | 160822T150249Z | Martin E |
| 1039 | Python 2 | 160821T140827Z | Copper |
| 306 | Fourier | 160821T132928Z | Beta Dec |
| 1643 | Whitespace | 160822T115538Z | Rolf |
| 220 | Marbelous | 160822T114216Z | jimmy230 |
| 373 | Hexagony | 160821T223427Z | Martin E |
| 381 | Actually | 160822T064445Z | Leaky Nu |
| 522 | Dyalog APL | 160821T135621Z | Adá |
| 1019 | Groovy | 160822T045326Z | M. Justi |
| 437 | ><> | 160821T192545Z | Sp3000 |
| 531 | ><> | 160821T173529Z | DanTheMa |
| 604 | Minkolang 0.15 | 160821T193838Z | El'e |
| 417 | 05AB1E | 160821T194409Z | Emigna |
| 1068 | JavaScript ES6 | 160821T163614Z | Neil |
| 477 | Brachylog | 160821T145110Z | Leaky Nu |
| 368 | WolframAlpha | 160821T164251Z | Anastasi |
| 413 | BBC Basic | 160821T153938Z | Level Ri |
| 297 | MATL | 160821T140138Z | DJMcMayh |
| 869 | Ruby | 160821T145031Z | lynn |
| 269 | CJam | 160821T133525Z | xenia |
| 355 | Pyke | 160821T132510Z | Blue |
Zsh, 1079 1042 bytes
Most programs are of the form <<<$'\nnn' where nnn is the octal codepoint of the ASCII symbol. So the normal programs range from <<<$'\40' to <<<$'\176'.
<<<$'\40' # Space
<<<$'\41' # !
<<<$'\42' # "
<<<$'\43' # #
The exceptions occur with the characters <$'\, and when the numbers 0-7 intersect with octals 60-67
echo \\044 # $
echo \\047 # '
jot -c 1 48 # 0 (octal 60)
<<<${(#)$((49))} # 1 (octal 61)
jot -c 1 50 # 2 (octal 62)
jot -c 1 51 # 3
jot -c 1 52 # 4
jot -c 1 $[49+4] # 5
jot -c 1 54 # 6
jot -c 1 55 # 7
echo \\074 # <
jot -c 1 92 # \
Vyxal, score 241 (non-competing :/)
ð
33C
34C
35C
36C
37C
38C
39C
40C
41C
×
43C
44C
45C
46C
47C
›
⇧
2›
3›
4›
5›
6›
7›
8›
9›
58C
59C
60C
61C
62C
63C
64C
65C
66C
\c⇧
68C
69C
70C
71C
72C
73C
74C
75C
76C
77C
78C
79C
80C
81C
82C
83C
84C
85C
86C
87C
88C
89C
90C
91C
92C
93C
94C
95C
96C
«ƛ
«¬
«∧
«⟑
«∨
«⟇
«÷
«×
«
«»
«°
«•
«ß
Ǡ
«€
«½
«∆
«ø
«↔
«¢
«⌐
«æ
«ʀ
«ʁ
«ɾ
«ɽ
⁺⌐C
⁺æC
⁺ʀC
⁺ʁC
Try it Online! (won't work as all of these need to be full programs)
Every printable ASCII character aside from 0123456789C *abcdefghijklmnoopqrstuvwxyz is represented as <charcode>C. The charcodes of {|}~ are represented using the compressed integers ⁺⌐, ⁺æ, ⁺ʀ, and ⁺ʁ. The score of these totals 168.
and * are respectively represented as ð and ×, score 2. a-z are represented as the compressed strings«ƛ, «¬, «∧ etc, score 52. C is represented as \c⇧, score 3. Out of the digits, 0 is represented by the empty string, 1 and 2 are represented by › and ⇧ respectively, and the other seven are represented by <n-1>›, for a total score of 16.
The total score is 241.
Vyxal 3, score 268 (non-competing)
Every character other than those listed below is of the pattern <charcode>O.
space > ð
* > •
0 > 1v
1-9 > <0-8>ꜝ
@ > ₄O
A > mh
O > 'oɾ
Z > mt
d > ₅O
e-z > '<E-Z>ʀ
| > kDh
} > 5⁻O
~ > kPt
PHP -r (891 680 674 bytes, 2 0 DNP)
Edit: saved 203 bytes thanks to jimmy23013 and implemented the 2 DNP thanks to Mego
This answer heavily abuses PHP's generous nature. Most of the cases take one of these forms (7 bytes each):
<?=Y^x;
<?=Z&e;
<?=V|Z;
PHP converts the letters on either side of the operator to strings, then performs the appropriate bitwise operation by converting each string to its ASCII character value, and finally converts the result back to a character.
In the first example above, Y^x becomes 89^78. The result of this is 33, which is then sent to STDOUT as the character !.
A script was written to bruteforce all possible combinations: the results can be found here.
Exceptions:
; is <?=Z^a?> (8 bytes)
| is <?='9'^E; (9 bytes)
< and ? would normally be DNP due to the required start tag, but by using the -r flag, code can be executed without them:
< is echo Z^f; (9 bytes)
? is echo Z^e; (9 bytes)
= is echo Z^g; (9 bytes)
Score:
(7 * 90) + 8 + 9 + 9 + 9 + 9 = 674 bytes
Pascal, 3828
The first program requires a processor supporting ISO standard 10206 “Extended Pascal” features, in particular the empty string ''.
Furthermore, the implementation‑defined set of char values as well as their respective ordinal values must match ASCII.
Technically, Pascal does not dictate any particular character set.
program s(output);begin write('':1)end.
NB: The above first program uses horizontal tabulation characters as blanks.
program b(output);begin write(chr(33))end.
program i(output);begin write(chr(34))end.
program o(output);begin write(chr(35))end.
program d(output);begin write(chr(36))end.
program p(output);begin write(chr(37))end.
program a(output);begin write(chr(38))end.
program p(output);begin write(chr(39))end.
program a(output);begin write(chr(42))end.
program p(output);begin write(chr(43))end.
program d(output);begin write(chr(44))end.
program d(output);begin write(chr(45))end.
program s(output);begin write(chr(47))end.
program z(output);begin write(1-1:1)end.
program o(output);begin write(3-2:3-2)end.
program o(output);begin write(chr(49))end.
program t(output);begin write(1+1:1)end.
program t(output);begin write(1+2:1)end.
program f(output);begin write(2+2:1)end.
program f(output);begin write(3+2:1)end.
program s(output);begin write(5+1:1)end.
program s(output);begin write(3+4:1)end.
program e(output);begin write(2*4:1)end.
program n(output);begin write(3*3:1)end.
program c(output);begin write(chr(58))end.
program l(output);begin write(chr(60))end.
program e(output);begin write(chr(61))end.
program g(output);begin write(chr(62))end.
program q(output);begin write(chr(63))end.
program a(output);begin write(chr(64))end.
program a(output);begin write(chr(65))end.
program b(output);begin write(chr(66))end.
program c(output);begin write(chr(67))end.
program d(output);begin write(chr(68))end.
program e(output);begin write(chr(69))end.
program f(output);begin write(chr(70))end.
program g(output);begin write(chr(71))end.
program h(output);begin write(chr(72))end.
program i(output);begin write(chr(73))end.
program j(output);begin write(chr(74))end.
program k(output);begin write(chr(75))end.
program l(output);begin write(chr(76))end.
program m(output);begin write(chr(77))end.
program n(output);begin write(chr(78))end.
program o(output);begin write(chr(79))end.
program p(output);begin write(chr(80))end.
program q(output);begin write(chr(81))end.
program r(output);begin write(chr(82))end.
program s(output);begin write(chr(83))end.
program t(output);begin write(chr(84))end.
program u(output);begin write(chr(85))end.
program v(output);begin write(chr(86))end.
program w(output);begin write(chr(87))end.
program x(output);begin write(chr(88))end.
program y(output);begin write(chr(89))end.
program z(output);begin write(chr(90))end.
program b(output);begin write(chr(91))end.
program b(output);begin write(chr(92))end.
program b(output);begin write(chr(93))end.
program c(output);begin write(chr(94))end.
program u(output);begin write(chr(95))end.
program b(output);begin write(chr(96))end.
progrAm A(output);begin write(chr(97))end.
program B(output);Begin write(chr(98))end.
program C(output);begin write(Chr(99))end.
program D(output);begin write(chr(100))end.
program E(output);bEgin writE(chr(101))End.
program F(output);begin write(chr(102))end.
proGram G(output);beGin write(chr(103))end.
program H(output);begin write(cHr(104))end.
program I(output);begIn wrIte(chr(105))end.
program J(output);begin write(chr(106))end.
program K(output);begin write(chr(107))end.
program L(output);begin write(chr(108))end.
prograM M(output);begin write(chr(109))end.
program N(output);begiN write(chr(110))eNd.
prOgram O(Output);begin write(chr(111))end.
Program P(outPut);begin write(chr(112))end.
program Q(output);begin write(chr(113))end.
pRogRam R(output);begin wRite(chR(114))end.
program S(output);begin write(chr(115))end.
program T(ouTpuT);begin wriTe(chr(116))end.
program U(oUtpUt);begin write(chr(117))end.
program V(output);begin write(chr(118))end.
program W(output);begin Write(chr(119))end.
program X(output);begin write(chr(120))end.
program Y(output);begin write(chr(121))end.
program Z(output);begin write(chr(122))end.
program b(output);begin write(chr(123))end.
program p(output);begin write(chr(124))end.
program b(output);begin write(chr(125))end.
program t(output);begin write(chr(126))end.
DNP: Parentheses, semicolon, or period cannot be omitted from the source code.
Boolean:
Theoretically you could use 2>1:1 to print the letter T (and a false expression for the letter F).
However, the casing, whether it is uppercase or lowercase, is implementation‑defined.
The GNU Pascal Compiler emits True/False, the FreePascal Compiler emits TRUE/FALSE or True/False in an ISO compiler compatibility mode.
jq, 991 bytes
Most characters, 8*80=640 bytes
For most characters, the shortest solution is simple. For instance, A is produced by the following program:
"\u0041"
This pattern is used for the following 80 characters:
!#$%&'()*+,-./:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^_`abcdefghijkmopqrstvwxyz{|}~
Digits, 3*10=30 bytes
We can easily use arithmetic to produce digits using 3 bytes each, like
1-1
and
3-2
and
1+1
and
1+2
and
2+2
and
2+3
and so on
" and \, 12*2=24 bytes
Since the usual pattern of "\u00xx" contains these characters, we can't use it here. Instead, we use the implode filter to construct a string from an array of codepoints. For " it looks like so:
[32]|implode
Flags, 2*10+3*85=275 bytes
By default, jq runs its program once per input value. To ensure the program outputs exactly one character, this must be avoided using either the -n or -s flag, adding two bytes to each program. Most programs don't care which, but one or the other is needed.
Additionally, output is usually written as json, meaning any string we output gets surrounded by double quotes. Thus for all programs except the 10 that output numbers, we need another flag to tell it not to do that, meaning we're using -rn (or -rs) for those programs, adding yet another byte.
.
u, 8 bytes, uses -n flag
We can't use the usual pattern for u. However, since we need either -n or -s anyway, assuming a null input from -n is free. We can use that with string formatting and slicing:
@sh[1:2]
n and l, 7*2=14 bytes, uses -n flag
We can modify the above approach to produce n and l, saving one byte each over the "\u00xx" approach, since the flag is there anyway:
@sh[:1]
and
@sh[3:]
Pip, 388 389 383 bytes
Most characters are computed using the Chr operator with their ASCII codes. Digits are (mostly) computed by incrementing the previous digit with U. Lowercase letters are (mostly) computed by indexing into z, the lowercase alphabet, since this is shorter for a few of them and breaks even for most of the rest. Here are the other exceptions:
sis a builtin for spaceiis a builtin for0ois a builtin for1AZ@2indexes into the builtin uppercase alphabet forC, avoiding theChr operatorChis shorter fordthanz@3z@tis shorter forkthanz@10C122avoids usingzforz
Here's the full list:
s
! C33
" C34
# C35
$ C36
% C37
& C38
' C39
( C40
) C41
* C42
+ C43
, C44
- C45
. C46
/ C47
0 i
1 o
2 U1
3 U2
4 U3
5 U4
6 U5
7 U6
8 U7
9 U8
: C58
; C59
< C60
= C61
> C62
? C63
@ C64
A C65
B C66
C AZ@2
D C68
E C69
F C70
G C71
H C72
I C73
J C74
K C75
L C76
M C77
N C78
O C79
P C80
Q C81
R C82
S C83
T C84
U C85
V C86
W C87
X C88
Y C89
Z C90
[ C91
\ C92
] C93
^ C94
_ C95
` C96
a @z
b z@1
c z@2
d Ch
e z@4
f z@5
g z@6
h z@7
i z@8
j z@9
k z@t
l z@11
m z@12
n z@13
o z@14
p z@15
q z@16
r z@17
s z@18
t z@19
u z@20
v z@21
w z@22
x z@23
y z@24
z C122
{ C123
| C124
} C125
~ C126
Perl 5: 1074 bytes
Translation of the Perl 6 version, thanks to @smls.
The programs are print"\x<hex code>"
Exceptions:
Numbers are calculated and printed like print n+1 or print n-1
The special chars needed for hex code (", \, x) are printed as print chr <hex code>
The chars out of "print" are printed in an eval like eval"print'\x<hexcode>'" and replacing the char in print with its hexcode.
-> print"\x20"
!-> print"\x21"
"-> print chr 34
#-> print"\x23"
$-> print"\x24"
%-> print"\x25"
&-> print"\x26"
'-> print"\x27"
(-> print"\x28"
)-> print"\x29"
*-> print"\x2A"
+-> print"\x2B"
,-> print"\x2C"
--> print"\x2D"
.-> print"\x2E"
/-> print"\x2F"
0-> print 1-1
1-> print 3-2
2-> print 1+1
3-> print 2+1
4-> print 3+1
5-> print 4+1
6-> print 5+1
7-> print 6+1
8-> print 7+1
9-> print 8+1
:-> print"\x3A"
;-> print"\x3B"
<-> print"\x3C"
=-> print"\x3D"
>-> print"\x3E"
?-> print"\x3F"
@-> print"\x40"
A-> print"\x41"
B-> print"\x42"
C-> print"\x43"
D-> print"\x44"
E-> print"\x45"
F-> print"\x46"
G-> print"\x47"
H-> print"\x48"
I-> print"\x49"
J-> print"\x4A"
K-> print"\x4B"
L-> print"\x4C"
M-> print"\x4D"
N-> print"\x4E"
O-> print"\x4F"
P-> print"\x50"
Q-> print"\x51"
R-> print"\x52"
S-> print"\x53"
T-> print"\x54"
U-> print"\x55"
V-> print"\x56"
W-> print"\x57"
X-> print"\x58"
Y-> print"\x59"
Z-> print"\x5A"
[-> print"\x5B"
\-> print chr 92
]-> print"\x5D"
^-> print"\x5E"
_-> print"\x5F"
`-> print"\x60"
a-> print"\x61"
b-> print"\x62"
c-> print"\x63"
d-> print"\x64"
e-> print"\x65"
f-> print"\x66"
g-> print"\x67"
h-> print"\x68"
i-> eval"pr\x69nt'\x69'"
j-> print"\x6A"
k-> print"\x6B"
l-> print"\x6C"
m-> print"\x6D"
n-> eval"pri\x6Et'\x6E'"
o-> print"\x6F"
p-> eval"\x70rint'\x70'"
q-> print"\x71"
r-> eval"p\x72int'\x72'"
s-> print"\x73"
t-> eval"prin\x74'\x74'"
u-> print"\x75"
v-> print"\x76"
w-> print"\x77"
x-> print chr 120
y-> print"\x79"
z-> print"\x7A"
{-> print"\x7B"
|-> print"\x7C"
}-> print"\x7D"
~-> print"\x7E"
G++, 3050B
It may be possible to output t by asm, but I do not quite know about the one on tio
#import<cstdio>-Df=putchar(32)
! #import<cstdio>-Df=putchar(33)
" #import<cstdio>-Df=putchar(34)
# extern"C"{int puts(...);}-Df=puts("\63")
$ #import<cstdio>-Df=putchar(36)
% #import<cstdio>-Df=putchar(37)
& #import<cstdio>-Df=putchar(38)
' #import<cstdio>-Df=putchar(39)
( #import<iostream>-Df=std::cout<<'\70'
) #import<iostream>-Df=std::cout<<'\71'
* #import<cstdio>-Df=putchar(42)
+ #import<cstdio>-Df=putchar(43)
, #import<cstdio>-Df=putchar(44)
- #import<cstdio> #define f putchar(45)
. #import<cstdio>-Df=putchar(46)
/ #import<cstdio>-Df=putchar(47)
0 #import<cstdio>-Df=putchar(48)
1 #import<cstdio>-Df=putchar(49)
2 #import<cstdio>-Df=putchar(50)
3 #import<cstdio>-Df=putchar(51)
4 #import<cstdio>-Df=putchar(52)
5 #import<cstdio>-Df=putchar(48+6)
6 #import<cstdio>-Df=putchar(54)
7 #import<cstdio>-Df=putchar(55)
8 #import<cstdio>-Df=putchar(56)
9 #import<cstdio>-Df=putchar(57)
: #import<cstdio>-Df=putchar(58)
; #import<cstdio>-Df=putchar(59)
< #import"cstdio"-Df=putchar(60)
= #import<cstdio> #define f putchar(61)
> #import"cstdio"-Df=putchar(62)
? #import<cstdio>-Df=putchar(63)
@ #import<cstdio>-Df=putchar(64)
A #import<cstdio>-Df=putchar(65)
B #import<cstdio>-Df=putchar(66)
C #import<cstdio>-Df=putchar(67)
D #import<cstdio> #define f putchar(68)
E #import<cstdio>-Df=putchar(69)
F #import<cstdio>-Df=putchar(70)
G #import<cstdio>-Df=putchar(71)
H #import<cstdio>-Df=putchar(72)
I #import<cstdio>-Df=putchar(73)
J #import<cstdio>-Df=putchar(74)
K #import<cstdio>-Df=putchar(75)
L #import<cstdio>-Df=putchar(76)
M #import<cstdio>-Df=putchar(77)
N #import<cstdio>-Df=putchar(78)
O #import<cstdio>-Df=putchar(79)
P #import<cstdio>-Df=putchar(80)
Q #import<cstdio>-Df=putchar(81)
R #import<cstdio>-Df=putchar(82)
S #import<cstdio>-Df=putchar(83)
T #import<cstdio>-Df=putchar(84)
U #import<cstdio>-Df=putchar(85)
V #import<cstdio>-Df=putchar(86)
W #import<cstdio>-Df=putchar(87)
X #import<cstdio>-Df=putchar(88)
Y #import<cstdio>-Df=putchar(89)
Z #import<cstdio>-Df=putchar(90)
[ #import<cstdio>-Df=putchar(91)
\ #import<cstdio>-Df=putchar(92)
] #import<cstdio>-Df=putchar(93)
^ #import<cstdio>-Df=putchar(94)
_ #import<cstdio>-Df=putchar(95)
` #import<cstdio>-Df=putchar(96)
a #import<cstdio>-Df=puts("\x61")
b #import<cstdio>-Df=putchar(98)
c #import<stdio.h>-Df=puts("\x63")
d extern"C"{int puts(...);}-Df=puts("\x64")
e #import<cstdio>-Df=putchar(101)
f #import<cstdio>-Dg=putchar(102)
g #import<cstdio>-Df=putchar(103)
h #import<cstdio>-Df=puts("\x68")
i extern"C"{char puts(...);}-Df=puts("\x69")
j #import<cstdio>-Df=putchar(106)
k #import<cstdio>-Df=putchar(107)
l #import<cstdio>-Df=putchar(108)
m #include<cstdio>-Df=putchar(109)
n #import<cstdio>-Df=putchar(110)
o extern"C"{int puts(...);}-Df=puts("\x6f")
p #include<iostream>-Df=std::cout<<'\x70'
q #import<cstdio>-Df=putchar(113)
r #include<cstdio>-Df=puts("\x72")
s extern"C"{int putchar(...);}-Df=putchar("\x73")
t main(){__asm__(".asciz \"\\xe8\\1\\0\\0\\0\\164Yj\\1[j\\1Zj\\4X\\xcd\\x80ó\"");} // Thanks to ceilingcat
u #import<cstdio>-Df=fwrite("\x75",1,1,&stdin[-2])
v #import<cstdio>-Df=putchar(118)
w #import<cstdio>-Df=putchar(119)
x #import<cstdio>-Df=putchar(120)
y #import<cstdio>-Df=putchar(121)
z #import<cstdio>-Df=putchar(122)
{ #import<cstdio>-Df=putchar(123)
| #import<cstdio>-Df=putchar(124)
} #import<cstdio>-Df=putchar(125)
~ #import<cstdio>-Df=putchar(126)
Japt, 150 bytes (59 characters completed)
A non-competitive work in progress (36 "DNP"s currently)
(I will be doing all 95 characters)
Oh, I'm enjoying this! :) This is the sort of challenge ETH, Oliver & I would have had great fun collaborating on back in the day.
Note that I have deliberately opted for a non-competitive solution to allow me to use non-ASCII characters and, therefore, some Japt trickery in places.
Being restricted to ASCII-only makes this challenge pretty trivial in Japt - every character (bar 5 & d) can be done in 3-4 bytes at most with Japt's method for converting character codes to strings.
I do plan to take another pass over this eventually to add an alternative set of ASCII-only solutions, hopefully more creative than that. But, equally, I may not ever get around to it!
| Name | Code | Link |
|---|---|---|
| Space | S |
Test it |
| Exclamation | g¦ |
Test it |
| Quotation | Q |
Test it |
| Hash | 35d |
Test it |
| Dollar | ;Gd |
Test it |
| Percentage | 37d |
Test it |
| Ampersand | g© |
Test it |
| Apostrophe | Hd7 |
Test it |
| Left Bracket | d40 |
Test it |
| Right Bracket | K¤Ì |
Test it |
| Asterisk | gÑ |
Test it |
| Plus | gÄ |
Test it |
| Comma | ;J |
Test it |
| Minus | gÉ |
Test it |
| Full Stop | ;L |
Test it |
| Forward Slash | 47d |
Test it |
| Zero | g |
Test it |
| One | l |
Test it |
| Two | (¤ |
Test it |
| Three | (³ |
Test it |
| Four | 2p |
Test it |
| Five | Az |
Test it |
| Six | 3Ñ |
Test it |
| Seven | 6Ä |
Test it |
| Eight | Iq |
Test it |
| Nine | AÉ |
Test it |
| Colon | d58 |
Test it |
| Semi-Colon | 59d |
Test it |
| Less Than | g§ |
Test it |
| Equals | g¥ |
Test it |
| Greater Than | g¨ |
Test it |
| Question | dÓI |
Test it |
| At | Id |
Test it |
| Uppercase A | ;BÎ |
Test it |
| Uppercase B | 2dI |
Test it |
| Uppercase C | Id3 |
Test it |
| Uppercase D | Id4 |
Test it |
| Uppercase E | Id5 |
Test it |
| Uppercase F | Id6 |
Test it |
| Uppercase G | Id7 |
Test it |
| Uppercase H | Id8 |
Test it |
| Uppercase I | Id9 |
Test it |
| Uppercase J | IdA |
Test it |
| Uppercase K | IdB |
Test it |
| Uppercase L | IdC |
Test it |
| Uppercase M | IdD |
Test it |
| Uppercase N | IdE |
Test it |
| Uppercase O | IdF |
Test it |
| Uppercase P | IdG |
Test it |
| Uppercase Q | ;DÎ |
Test it |
| Uppercase R | 82d |
Test it |
| Uppercase S | 83d |
Test it |
| Uppercase T | 84d |
Test it |
| Uppercase U | 85d |
Test it |
| Uppercase V | 86d |
Test it |
| Uppercase W | 87d |
Test it |
| Uppercase X | 88d |
Test it |
| Uppercase Y | 89d |
Test it |
| Uppercase Z | 90d |
Test it |
| Left Square Bracket | ... | ... |
C# (Mono C# Shell), 464 bytes
Most programs are of the form
"\x##"
where ## is the 2 digit hex identifier for each character. For example, "\x2A" yields "+". The 13 exceptions are all the digits, ", \ and x:
1-1 //0
-~0 //1
-~1 //2
-~2 //3
-~3 //4
-~4 //5
-~5 //6
-~6 //7
-~7 //8
-~8 //9
(char)34 //"
(char)92 //\
"\u0078" //x
Score: (95-13) * 5 + 10 * 3 + 3 * 8
C (gcc) 2073 bytes
All programs use the following form:
main(){putchar(n);}
Except for the following:
| Character | Code | Flags | Demo |
|---|---|---|---|
| ( | main _){putchar _ 40);} |
-D_=( | TIO |
| ) | main(_{putchar(41 _;} |
-D_=) | TIO |
| 5 | main(){putchar(44+9);} |
TIO | |
| ; | main(){if(putchar(59)){}} |
TIO | |
| a | s(){exit(puts("\141"));} |
-nostartfiles | TIO |
| c | main(){puts("\143");} |
TIO | |
| h | main(){puts("\150");} |
TIO | |
| i | s(){putchar(105),abort();}} |
-nostartfiles | TIO |
| m | s(){exit(putchar(109));} |
-nostartfiles | TIO |
| n | s(){exit(putchar(110));} |
-nostartfiles | TIO |
| p | x=112;main(){write(1,&x,1);} |
TIO | |
| r | main(){puts("\162");} |
TIO | |
| t | x=116;main(){syscall(1,1,&x,1);} |
TIO | |
| u | main(){printf("\165");} |
TIO | |
| { | main()<%putchar(123);} |
TIO | |
| } | main(){putchar(125);%> |
TIO |
Complete List:
main(){putchar(32);}
main(){putchar(33);}
main(){putchar(34);}
main(){putchar(35);}
main(){putchar(36);}
main(){putchar(37);}
main(){putchar(38);}
main(){putchar(39);}
main _){putchar _ 40);}
main(_{putchar(41 _;}
main(){putchar(42);}
main(){putchar(43);}
main(){putchar(44);}
main(){putchar(45);}
main(){putchar(46);}
main(){putchar(47);}
main(){putchar(48);}
main(){putchar(49);}
main(){putchar(50);}
main(){putchar(51);}
main(){putchar(52);}
main(){putchar(44+9);}
main(){putchar(54);}
main(){putchar(55);}
main(){putchar(56);}
main(){putchar(57);}
main(){putchar(58);}
main(){if(putchar(59)){}}
main(){putchar(60);}
main(){putchar(61);}
main(){putchar(62);}
main(){putchar(63);}
main(){putchar(64);}
main(){putchar(65);}
main(){putchar(66);}
main(){putchar(67);}
main(){putchar(68);}
main(){putchar(69);}
main(){putchar(70);}
main(){putchar(71);}
main(){putchar(72);}
main(){putchar(73);}
main(){putchar(74);}
main(){putchar(75);}
main(){putchar(76);}
main(){putchar(77);}
main(){putchar(78);}
main(){putchar(79);}
main(){putchar(80);}
main(){putchar(81);}
main(){putchar(82);}
main(){putchar(83);}
main(){putchar(84);}
main(){putchar(85);}
main(){putchar(86);}
main(){putchar(87);}
main(){putchar(88);}
main(){putchar(89);}
main(){putchar(90);}
main(){putchar(91);}
main(){putchar(92);}
main(){putchar(93);}
main(){putchar(94);}
main(){putchar(95);}
main(){putchar(96);}
s(){exit(puts("\141"));}
main(){putchar(98);}
main(){puts("\143");}
main(){putchar(100);}
main(){putchar(101);}
main(){putchar(102);}
main(){putchar(103);}
main(){puts("\150");}
s(){putchar(105),abort();}}
main(){putchar(106);}
main(){putchar(107);}
main(){putchar(108);}
s(){exit(putchar(109));}
s(){exit(putchar(110));}
main(){putchar(111);}
x=112;main(){write(1,&x,1);}
main(){putchar(113);}
main(){puts("\162");}
main(){putchar(115);}
x=116;main(){syscall(1,1,&x,1);}
main(){printf("\165");}
main(){putchar(118);}
main(){putchar(119);}
main(){putchar(120);}
main(){putchar(121);}
main(){putchar(122);}
main()
main(){putchar(126);}
MathGolf, 268 characters/bytes, 0 DNF's
Each line is a separated program:
'!(
U$
V$
W$
'#)
Y$
Z$
Z)$
'')
'*(
'))
'*)
'+)
',)
'-)
'.)
+
)
1)
2)
3)
4)
5)
6)
7)
8)
'9)
':)
';)
'<)
'=)
'>)
'?)
'@)
'A)
'B)
'C)
'D)
'E)
'F)
'G)
'H)
'I)
'J)
'K)
'L)
'M)
'N)
'O)
'P)
'Q)
'R)
'S)
'T)
'U)
'V)
'W)
'X)
'Y)
'Z)
'[)
'\)
'])
'^)
'_)
'`)
'a)
'b)
'c)
'd)
'e)
'f)
'g)
'h)
'i)
'j)
'k)
'l)
'm)
'n)
'o)
'p)
'q)
'r)
's)
't)
'u)
'v)
'w)
'x)
'y)
'z)
'{)
'|)
'})
Explanation:
!"#%&: Push constant integers with this codepoint (U=33 throughZ=38, except forX=36), and convert it from an integer to a character with$': Same, but withZincremented to 39 with)before the$0:+in an empty program without input, it'll implicitly use0for mathematical builtins, so it'll implicitly do0+0, which results in01:)increments once, so just like the+it'll implicitly use a0, which gets incremented to123456789: push the previous digit, and increment it once with)): push character'*'and decrement it with(- every other character: push the previous character with
'and increment it with)
Making it non-competitive by also using non-ASCII characters would make some of them shorter (247 bytes):
'!((space character) could be♥$: try it online'))(character*) could be⌂: try it online'')/'*(/'*)/'+)(characters()+,) could be⌂⌡/⌂(/⌂)/⌂⌠respectively: try it online'-)/'.)(characters./) could beΩ⌡/Ω(respectively: try it online';)(character<) could be╟$: try it online'?)(character@) could be♦$: try it online'@)(characterA) could be♂¢: try it online'A)through'E)(charactersBthroughF) could beA¢throughE¢: try it online'H)(characterI) could be7╦: try it online'`)(charactera) could be4╦: try it online'c)(characterd) could be♀$: try it online'h)(characteri) could be╩j: try it online
J, 870 bytes
Extremely boring right now, but I am hoping to find ways to golf this further. So far, only the numbers are golfed. Nearly every program is of the form echo u:xx, where xx is the ascii code. The exceptions are for the characters [echo u:0-9]. For the letters, I used 1!:2&2 u:xx. Most numbers are printed using echo>:x, which just increments some number, except for 0, 1, and 6.
echo@u:32 : SPACE
echo?1 : 0
echo*2 : 1
echo!3 : 6
echo 58{a. : :
1!:2&2 u:99 : c
Total score is computed via: 12*4 + 11 + 10*24 + 9*56 + 7*7 + 6*3 = 870
or via
p DATA.readlines.sum{_1.chomp.size} #=> 870
__END__
echo@u:32
echo u:33
echo u:34
echo u:35
echo u:36
...
Knight, 489 characters
Not a terribly interesting challenge for Knight. The general scheme is O A<ascii encoding>. This leaves three interesting cases: O, A, and digits.
- Coincidentally, the only number which needs to be fixed is
5. So instead ofO A53, we doO A+9 44. - The
Ois a DNP, as it's the only way to do output. (TechnicallyDUMPcan too, but it doesnt output only its argument.) - The
Aone is a bit interesting; it's not immediately obvious that it's not possible. However, the only way to get strings that you didnt write in the source code is either (1) convert true/false/null/integers to a string or (2) useASCII.FALSEalmost does it, except it converts to the lower-casefalse, notFALSE. So,Ais also DNP.
Test cases for those curious
O A33 # !
O A34 # "
O A35 # #
O A36 # $
O A37 # %
O A38 # &
O A39 # '
O A40 # (
O A41 # )
O A42 # *
O A43 # +
O A44 # ,
O A45 # -
O A46 # .
O A47 # /
O A48 # 0
O A49 # 1
O A50 # 2
O A51 # 3
O A52 # 4
O A+9 44 # 5
O A54 # 6
O A55 # 7
O A56 # 8
O A57 # 9
O A58 # :
O A59 # ;
O A60 # <
O A61 # =
O A62 # >
O A63 # ?
O A64 # @
# A, DNP
O A66 # B
O A67 # C
O A68 # D
O A69 # E
O A70 # F
O A71 # G
O A72 # H
O A73 # I
O A74 # J
O A75 # K
O A76 # L
O A77 # M
O A78 # N
# O, DNP
O A80 # P
O A81 # Q
O A82 # R
O A83 # S
O A84 # T
O A85 # U
O A86 # V
O A87 # W
O A88 # X
O A89 # Y
O A90 # Z
O A91 # [
O A92 # \
O A93 # ]
O A94 # ^
O A95 # _
O A96 # `
O A97 # a
O A98 # b
O A99 # c
O A100 # d
O A101 # e
O A102 # f
O A103 # g
O A104 # h
O A105 # i
O A106 # j
O A107 # k
O A108 # l
O A109 # m
O A110 # n
O A111 # o
O A112 # p
O A113 # q
O A114 # r
O A115 # s
O A116 # t
O A117 # u
O A118 # v
O A119 # w
O A120 # x
O A121 # y
O A122 # z
O A123 # {
O A124 # |
O A125 # }
O A126 # ~
Python3, 2646 characters + 7 DNP
In Python3.7.1, the following program code returns all 95 printable-ascii characters on each line using the following format starting with the empty space " " character for 32, and ending with the Tilde character "~" for 127.
The following code added to a .py file will execute the output of all printable ascii, with seven instances that don't conform (labeled DNF) for the seven characters here print() and modifications were made for the characters bytesrangin order to avoid duplicates:
print(bytes(range(32,33))),
print(bytes(range(33,34))),
print(bytes(range(34,35))),
print(bytes(range(35,36))),
print(bytes(range(36,37))),
print(bytes(range(37,38))),
print(bytes(range(38,39))),
print(bytes(range(39,40))),
print(bytes(range(40,41))),#( DNP
print(bytes(range(41,42))),#) DNP
print(bytes(range(42,43))),
print(bytes(range(43,44))),
print(chr(44)),
print(bytes(range(45,46))),
print(bytes(range(46,47))),
print(bytes(range(47,48))),
print(bytes(range(48,49))),
print(bytes(range(49,50))),
print(bytes(range(50,51))),
print(bytes(range(51,52))),
print(bytes(range(52,53))),
print(bytes(range(53,54))),
print(bytes(range(54,55))),
print(bytes(range(55,56))),
print(bytes(range(56,57))),
print(bytes(range(57,58))),
print(bytes(range(58,59))),
print(bytes(range(59,60))),
print(bytes(range(60,61))),
print(bytes(range(61,62))),
print(bytes(range(62,63))),
print(bytes(range(63,64))),
print(bytes(range(64,65))),
print(bytes(range(65,66))),
print(bytes(range(66,67))),
print(bytes(range(67,68))),
print(bytes(range(68,69))),
print(bytes(range(69,70))),
print(bytes(range(70,71))),
print(bytes(range(71,72))),
print(bytes(range(72,73))),
print(bytes(range(73,74))),
print(bytes(range(74,75))),
print(bytes(range(75,76))),
print(bytes(range(76,77))),
print(bytes(range(77,78))),
print(bytes(range(78,79))),
print(bytes(range(79,80))),
print(bytes(range(80,81))),
print(bytes(range(81,82))),
print(bytes(range(82,83))),
print(bytes(range(83,84))),
print(bytes(range(84,85))),
print(bytes(range(85,86))),
print(bytes(range(86,87))),
print(bytes(range(87,88))),
print(bytes(range(88,89))),
print(bytes(range(89,90))),
print(bytes(range(90,91))),
print(bytes(range(91,92))),
print(bytes(range(92,93))),
print(bytes(range(93,94))),
print(bytes(range(94,95))),
print(bytes(range(95,96))),
print(bytes(range(96,97))),
print(chr(97)), #a
print(chr(98)), #b
print(bytes(range(99,100))),
print(bytes(range(100,101))),
print(chr(101)),#e
print(bytes(range(102,103))),
print(chr(103)),#g
print(bytes(range(104,105))),
print(bytes(range(105,106))), #i DNP
print(bytes(range(106,107))),
print(bytes(range(107,108))),
print(bytes(range(108,109))),
print(bytes(range(109,110))),
print(bytes(range(110,111))), #n DNP
print(bytes(range(111,112))),
print(bytes(range(112,113))),#p DNP
print(bytes(range(113,114))),
print(bytes(range(114,115))),#r DNP
print(chr(115)),#s
print(bytes(range(116,117))),#t DNP
print(bytes(range(117,118))),
print(bytes(range(118,119))),
print(bytes(range(119,120))),
print(bytes(range(120,121))),
print(chr(121)),#y
print(bytes(range(122,123))),
print(bytes(range(123,124))),
print(bytes(range(124,125))),
print(bytes(range(125,126))),
print(bytes(range(126,127))),
Note: I didn't make an exception for the ascii comma character (i.e. 44) as that isn't necessary in the program except when all programs are run from one file, as a line separator). And the letters after the # symbol are just comments.
The output (contains b to denote byte format, followed by quotation marks'):
b' '
b'!'
b'"'
b'#'
b'$'
b'%'
b'&'
b"'"
b'('
b')'
b'*'
b'+'
b','
b'-'
b'.'
b'/'
b'0'
b'1'
b'2'
b'3'
b'4'
b'5'
b'6'
b'7'
b'8'
b'9'
b':'
b';'
b'<'
b'='
b'>'
b'?'
b'@'
b'A'
b'B'
b'C'
b'D'
b'E'
b'F'
b'G'
b'H'
b'I'
b'J'
b'K'
b'L'
b'M'
b'N'
b'O'
b'P'
b'Q'
b'R'
b'S'
b'T'
b'U'
b'V'
b'W'
b'X'
b'Y'
b'Z'
b'['
b'\\'
b']'
b'^'
b'_'
b'`'
a
b
b'c'
b'd'
e
b'f'
g
b'h'
b'i'
b'j'
b'k'
b'l'
b'm'
b'n'
b'o'
b'p'
b'q'
b'r'
s
b't'
b'u'
b'v'
b'w'
b'x'
y
b'z'
b'{'
b'|'
b'}'
b'~'
R, 1040 bytes
-2 bytes by using as.name.
The credit for this answer should go to digEmAll, who did 499(!) bytes better than my version (left below). Most characters are printed by using the octal representation, e.g. cat('\041') prints character number 41 in octal, or 33 in decimal, i.e. !. There are a couple of minor additional tricks, explained in more detail in my original answer below. For the characters ct, use as.name instead of cat; for the characters () redefine the function ? which has a special syntax and doesn't need brackets.
The solution for a is
`c\141t`('\141')
since c\141t in backticks is interpreted as cat.
The other notable exception is the character \, for which we have to use the more standard cat(intToUtf8(92)).
cat('','')
cat('\041')
cat('\042')
cat('\043')
cat('\044')
cat('\045')
cat('\046')
cat("\047")
`?`=cat;?'\050'
`?`=cat;?'\051'
cat('\052')
cat('\053')
cat('\054')
cat('\055')
cat('\056')
cat('\057')
cat(+F)
cat(+T)
cat(1+1)
cat(2+1)
cat(3+1)
cat(4+1)
cat(5+1)
cat(6+1)
cat(7+1)
cat(8+1)
cat('\072')
cat('\073')
cat('\074')
cat('\075')
cat('\076')
cat('\077')
cat('\100')
cat('\101')
cat('\102')
cat('\103')
cat('\104')
cat('\105')
cat('\106')
cat('\107')
cat('\110')
cat('\111')
cat('\112')
cat('\113')
cat('\114')
cat('\115')
cat('\116')
cat('\117')
cat('\120')
cat('\121')
cat('\122')
cat('\123')
cat('\124')
cat('\125')
cat('\126')
cat('\127')
cat('\130')
cat('\131')
cat('\132')
cat('\133')
cat(intToUtf8(92))
cat('\135')
cat('\136')
cat('\137')
cat('\140')
`c\141t`('\141')
cat('\142')
as.name('\143')
cat('\144')
cat('\145')
cat('\146')
cat('\147')
cat('\150')
cat('\151')
cat('\152')
cat('\153')
cat('\154')
cat('\155')
cat('\156')
cat('\157')
cat('\160')
cat('\161')
cat('\162')
cat('\163')
as.name('\164')
cat('\165')
cat('\166')
cat('\167')
cat('\170')
cat('\171')
cat('\172')
cat('\173')
cat('\174')
cat('\175')
cat('\176')
Original version:
R, 1541 bytes
Most non-alphanumeric characters are of the form cat(intToUtf8(33)). The intToUtf8 part can be made shorter for most alphanumeric characters. The main issue is the characters cat(), which I will handle last.
For digits, simple operations like cat(1+1) work.
For letters, the shortest seems to be to use the constants letters and LETTERS (the alphabet) whenever possible, e.g. cat(LETTERS[1]) for A. This doesn't work for the characters LETRSletrs, for which we move to the slightly longer cat(toupper("l")) or cat(tolower("S")). For elr we have to revert to cat(intToUtf8(101)) and the like.
The code for the space can be made shorter with cat('',''), because cat will by default add spaces between strings (here two empty strings).
The brackets () are annoying: not using them seems to disallow calling functions. Here I used a standard R golfing technique, redefining some unary functions which have special syntax: cat(intToUtf8(40)) becomes
`?`=cat;`!`=intToUtf8;?!40
Finally, the letters cat. We need the cat() function, otherwise R will add some fluff; for example letters[1] or print(letters[1]) outputs [1] "a" instead of a. We'll need two distinct workarounds.
The function write is usually used to write to a file, but can be made to write to STDOUT: write(letters[1],'') works for a and c. Unfortunately, that still doesn't work for t. I almost gave up here...
Let's take a step back. The reason R adds [1] by default when printing is that most objects are of a vector type (here, a vector of length 1). The main exceptions are functions; in particular, calling for the body() or args() of a function doesn't add anything, but I couldn't find a way to use this. There are however internal non-vector types, such as promises, expressions and symbols (the latter are also called names), so a solution is to use as.name: as.name("t") converts the string to an object name, and outputs it at just t. I also used this for c, since as.name(letters[3]) is shorter than write(letters[3],'') (but we still need write for a).
We now need to find a way of creating the string "t", but cannot use letters, tolower or intToUtf8. The best I could come up with is as.name(rawToChar(as.raw(116))).
Full list:
cat('','')
cat(intToUtf8(33))
cat(intToUtf8(34))
cat(intToUtf8(35))
cat(intToUtf8(36))
cat(intToUtf8(37))
cat(intToUtf8(38))
cat(intToUtf8(39))
`?`=cat;`!`=intToUtf8;?!40
`?`=cat;`!`=intToUtf8;?!41
cat(intToUtf8(42))
cat(intToUtf8(43))
cat(intToUtf8(44))
cat(intToUtf8(45))
cat(intToUtf8(46))
cat(intToUtf8(47))
cat(1-1)
cat(3-2)
cat(1+1)
cat(2+1)
cat(3+1)
cat(4+1)
cat(5+1)
cat(6+1)
cat(7+1)
cat(8+1)
cat(intToUtf8(58))
cat(intToUtf8(59))
cat(intToUtf8(60))
cat(intToUtf8(61))
cat(intToUtf8(62))
cat(intToUtf8(63))
cat(intToUtf8(64))
cat(LETTERS[1])
cat(LETTERS[2])
cat(LETTERS[3])
cat(LETTERS[4])
cat(toupper("e"))
cat(LETTERS[6])
cat(LETTERS[7])
cat(LETTERS[8])
cat(LETTERS[9])
cat(LETTERS[10])
cat(LETTERS[11])
cat(toupper("l"))
cat(LETTERS[13])
cat(LETTERS[14])
cat(LETTERS[15])
cat(LETTERS[16])
cat(LETTERS[17])
cat(toupper("r"))
cat(toupper("s"))
cat(toupper("t"))
cat(LETTERS[21])
cat(LETTERS[22])
cat(LETTERS[23])
cat(LETTERS[24])
cat(LETTERS[25])
cat(LETTERS[26])
cat(intToUtf8(91))
cat(intToUtf8(92))
cat(intToUtf8(93))
cat(intToUtf8(94))
cat(intToUtf8(95))
cat(intToUtf8(96))
write(letters[1],'')
cat(letters[2])
as.name(letters[3])
cat(letters[4])
cat(intToUtf8(101))
cat(letters[6])
cat(letters[7])
cat(letters[8])
cat(letters[9])
cat(letters[10])
cat(letters[11])
cat(intToUtf8(108))
cat(letters[13])
cat(letters[14])
cat(letters[15])
cat(letters[16])
cat(letters[17])
cat(intToUtf8(114))
cat(tolower("S"))
as.name(rawToChar(as.raw(116)))
cat(letters[21])
cat(letters[22])
cat(letters[23])
cat(letters[24])
cat(letters[25])
cat(letters[26])
cat(intToUtf8(123))
cat(intToUtf8(124))
cat(intToUtf8(125))
cat(intToUtf8(126))
Reg (a.k.a. Unofficial Keg), 221 bytes
All programs here follow the pattern:
<character+1>;
However, there are some exceptions:
- Reg has 25 characters that are recognized as instructions. Therefore, they have to be escaped. These are:
! Pushes the length of the stack onto the stack
: Duplicates the last item on the stack
_ Removes the last item on the stack
, Prints the last item on the stack as a character
. Prints the last item on the stack as an integer
? Gets input from the user
' Left shifts the stack
" Right shifts the stack
~ Pushes a random number onto the stack
^ Reverses the stack
$ Swaps the top two items on the stack
# Starts a comment
| Branches to the next section of a structure
\ Escapes the next command, and pushes it as a string
& Gets/sets the register value
@ Define/call a function
+ Pops x and y and pushes y + x
- Pops x and y and pushes y - x
* Pops x and y and pushes y * x
/ Pops x and y and pushes y / x
% Pops x and y and pushes y % x
< Pops x and y and pushes y < x
> Pops x and y and pushes y > x
= Pops x and y and pushes y == x
; Decrement the top of the stack
{}[]() also needs escaping.
Length = 2*95+25+6=221B
Runic Enchantments, Score: (95*6)+3-(9*2)†-(32*1)‡ = 523
All programs:
25pk@
b3*k@
3´4k@
3´5k@
c3*k@
3´7k@
3´8k@
d3*k@
4Xk@
4´1k@
e3*k@
4´3k@
b4*k@
f3*k@
4´6k@
4´7k@
c4*k@
4´9k@
5Xk@
5´1k@
d4*k@
4´dk@
5´4k@
b5*k@
e4*k@
5´7k@
5´8k@
5´9k@
6Xk@
6´1k@
6´2k@
6´3k@
26pk$;
d5*k@
b6*k@
6´7k@
6´8k@
6´9k@
7Xk@
7´1k@
c6*k@
7´3k@
7´4k@
f5*k@
7´6k@
b7*k@
d6*k@
7´9k@
8Xk@
34pk@
8´2k@
8´3k@
e6*k@
8´5k@
8´6k@
8´7k@
b8*k@
8´9k@
9Xk@
d7*k@
9´2k@
9´3k@
9´4k@
9´5k@
c8*k@
9´7k@
e7*k@
b9*k@
aXk@
a´1k@
a´2k@
a´3k@
d8*k@
f7*k@
a´6k@
a´2E3%@
c9*k@
a´9k@
bXk@
b´1k@
e8*k@
b´3k@
b´4k@
b´5k@
b´6k@
d9*k@
b´8k@
b´9k@
cXk@
bb*k@
c´2k@
c´3k@
c´4k@
53pk@
e9*k@
´ does cost 2 bytes, but for a sequence like this, its convenient, and works out to be "as good as or shorter" for encoding nearly all number literals with values greater than 15. We can even cheat here and there with some values due to the way that the operation works. For example, the program that outputs 5 is written as 4´dk@ instead of 5´3k@, using the literal 13 instruction (4*10+13 vs 5*10+3). Only values that are a multiple of 10 (4X vs 4´0)(†) or that can be constructed using two values <16 and one basic math operation (+-*/%^)(‡) are cheaper without using ´.
The only one that gave me more than a moment's pause was k, as without k there's no way to convert a number to a character. I can't even use reflection to write it into the grid. But I can extract one from a string! a´2E3%@ pulls word 102 out of the dictionary ("back") and slices out its 3rd index ("k") and prints it.
Malbolge, 618 bytes.
This answer is pretty much obvious, and it's trivial to outgolf, but it may be worth to give a shot.
Jokes aside, I highly doubt you can golf it, just the ( and '<' ones.
:7 - (&<`M^\
!:7 - (C<;_"K
":7 - (&&$_L]
#:8 - (&<;_L\J
$:7 - D'<A:^K
%:8 - (=&;_L]J
&:7 - D'%`M#o
':6 - (&%`M^
(:16 - DCBA@?>~<;{98xUB
):8 - (&<%:^KJ
*:7 - (&<`M]>
+:7 - (&&;_L]
,:7 - (=&;_L>
-:6 - D'%%_L
.:7 - ('%`M9o
/:6 - (=B;_L
0:6 - ('%$_L
1:7 - (&a%M"o
2:8 - (=&;:^"J
3:7 - ('<;_L"
4:7 - ('%;_L]
5:6 - D'%`#L
6:6 - (=<`:L
7:7 - (&<;:^K
8:8 - ('&;$9]J
9:7 - ('<;:^K
::6 - (&%`M?
;:8 - (C<A:^"J
<:10 - ('&%#^"J~Z
=:7 - DC&$_#K
>:6 - (&%`#L
?:6 - (=<`@L
@:7 - (&B%:^K
A:7 - (&<`M^8
B:5 - (&a%M
C:6 - D'%`M#
D:6 - (&%`M"
E:7 - ('&$_L\
F:7 - (&%$:^K
G:6 - (&%;_L
H:7 - ('&;:^K
I:6 - (C<;_L
J:6 - D'<;_L
K:7 - (&a%M^!
L:7 - (=<;_#K
M:7 - ('%$#^K
N:7 - (&&;_#K
O:7 - DC&$:^K
P:5 - (&a;M
Q:8 - ('%A$9]J
R:6 - (&<`M?
S:7 - (&a%M]\
T:5 - (=a;M
U:6 - D'<%_L
V:5 - (&aAM
W:5 - (=aNM
X:6 - (=aN_#
Y:7 - (&&$:^K
Z:7 - DC&$_"K
[:7 - (&%$_"K
\:1 - Q
]:5 - ('<`M
^:6 - ('B;_L
_:6 - (&<`M#
`:7 - DC&;_L"
a:6 - ('%`M#
b:7 - ('%;_9K
c:5 - (&aN_
d:6 - (&<`:L
e:7 - (&%;_"K
f:6 - (=<;_L
g:7 - ('%;_#K
h:7 - (&a%M^"
i:7 - ('%`M^"
j:8 - (=B;:^"J
k:5 - ('%`M
l:5 - (&&`M
m:6 - (&%`:L
n:7 - D'%;_Lo
o:6 - (=aN_9
p:6 - (CB;_L
q:7 - D'%A:^K
r:4 - (=aN
s:5 - (C<`M
t:7 - (&%;_L]
u:5 - (&aN:
v:6 - D'%`:L
w:7 - (&B;:^K
x:5 - (=a$M
y:5 - D'<`M
z:7 - (&%%:^K
{:5 - (=aN_
|:5 - (&a$M
}:5 - (&aN#
~:7 - (&%$_L"
Pyth, 285 bytes
Most characters are just C<codepoint in decimal>: <space> (C32)-c (C99) are 3 characters each, d (C100)-~ (C126) are 4 characters each, for a base count of 3*68+4*27=312 bytes.
Exceptions
space: d (-2)
": N (-2)
0: Z (-2)
1-9: h0 ... h8 (-9, -1 each)
C: r\c1 (+1)
a: hG (-1)
d-j: @G3 ... @G9 (-7, -1 each)
k: @GT (-1)
y: ePG (-1)
z: eG (-2)
Total from exceptions: -26 bytes, for a grand total of 286 bytes.
33, 539 bytes, 3 DNP
Most programs take the form of: <Number>cktp, so I'll list the programs that are different:
The digit 0:
Since the accumulator is initialised to 0, I can just use o for it.
The digit 1:
Adding 1 to the accumulator isn't an option, so I evaluate 3 - 2 instead: 3c2mo
The digits 2 and 3:
Repeatedly adding 1 to the accumulator is shorter than printing the character code, so 1aao and 1aaao are used
The digit 4:
Repeatedly adding 2 to the accumulator works here: 2aao
The digit 5:
5 is the only number whose decimal representation in ASCII contains itself. What I can do instead is add 2 and 3: 2c3ao
The digit 6:
Double 3: 3aao
The digits 7 and 9:
These work much the same way as 5: 3c4ao and 5c4ao
The digit 8:
Double 4: 4aao
The letter c:
To get the number from the counter into the accumulator, I use c. This is replaceable with a, so there is very little problem there: 99aktp
The letters k, t, and p:
It is not possible to get a character into the source string and print it without these letters, so that's 3 DNP's.
Full listing:
This is full list of the programs, separated by newlines
32cktp
33cktp
34cktp
35cktp
36cktp
37cktp
38cktp
39cktp
40cktp
41cktp
42cktp
43cktp
44cktp
45cktp
46cktp
47cktp
o
3c2mo
1aao
1aaao
2aao
2c3ao
3aao
3c4ao
4aao
5c4ao
58cktp
59cktp
60cktp
61cktp
62cktp
63cktp
64cktp
65cktp
66cktp
67cktp
68cktp
69cktp
70cktp
71cktp
72cktp
73cktp
74cktp
75cktp
76cktp
77cktp
78cktp
79cktp
80cktp
81cktp
82cktp
83cktp
84cktp
85cktp
86cktp
87cktp
88cktp
89cktp
90cktp
91cktp
92cktp
93cktp
94cktp
95cktp
96cktp
97cktp
98cktp
99aktp
100cktp
101cktp
102cktp
103cktp
104cktp
105cktp
106cktp
108cktp
109cktp
110cktp
111cktp
113cktp
114cktp
115cktp
117cktp
118cktp
119cktp
120cktp
121cktp
122cktp
123cktp
124cktp
125cktp
126cktp
Pushy, 267 bytes
This answer takes advantage of the many output commands available.
Most programs are in the format
<char code>"or<char code>', which print the character with that char code.0:
Z#5:
4h#The first ten letters of the uppercase alphabet are printed using
<index>Q, where<index>is the letter's 0-based index in the alphabet:0Q, 1Q, 2Q... 9Q, TQ.All letters in the lowercase alphabet are pritned using
<index>q, apart from of courseq, which is printed using the first method.
The complete list of programs is below:
32"
33"
34'
35"
36"
37"
38"
39"
40"
41"
42"
43"
44"
45"
46"
47"
Z#
49"
50"
51"
52"
4h#
54"
55"
56"
57"
58"
59"
60"
61"
62"
63"
64"
0Q
1Q
2Q
3Q
4Q
5Q
6Q
7Q
8Q
9Q
TQ
76"
77"
78"
79"
80"
81"
82"
83"
84"
85"
86"
87"
88"
89"
90"
91"
92"
93"
94"
95"
96"
0q
1q
2q
3q
4q
5q
6q
7q
8q
9q
Tq
11q
12q
13q
14q
15q
113"
17q
18q
19q
20q
21q
22q
23q
24q
25q
123"
124"
125"
126"
Add++, 505 bytes
Almost all of the programs have the format
+<char code>
H
With the exception of 3, the programs that generate "5", "+" and "H", which are, respectively
+4
+1
O
x:43
H
+72
h
How they work:
- Most work by setting that active variable to their charcode, and
Hconverts numbers to characters when outputting "5"works simply by adding \$4\$ and \$1\$ and outputting the numerical result."+"works by setting the variable explicitly, rather than adding the value"H"works by usingh, which outputs the same result asH, without a trailing newline
The bytecount was calculated using this program.
SmileBASIC, 863 bytes
Almost every program will be of the form ?CHR$(number), except:
$ : ?LOAD("TXT:SYS/SBWAV",0)[394]
( : CHR$40OUT A$?A$
) : CHR$41OUT A$?A$
0 : ?.
1 : ?!.
2 : ?1+1
3 : ?2+1
Other digits: Continue pattern of 2 and 3
? : PRINT CHR$(63)
C : ?HEX$(12)
H : ?ChR$(72)
R : ?CHr$(82)
Forth, 694 bytes
The general form is:
<char-code> emit
Like 33 emit for !.
Exceptions:
-> SPACE
5 -> 106 2/ emit (or 49 4 + emit)
e -> 101 EMIT
i -> 105 EMIT
m -> 109 EMIT
t -> 116 EMIT
Unfortunately, using . prints a space at the end. If it were usable, I could save 10 bytes, one for each digit 0-9. They would've been printed using these:
1 1- .
2 2/ .
1 1+ .
2 1+ .
3 1+ .
4 1+ .
5 1+ .
6 1+ .
7 1+ .
8 1+ .
Befunge-93, 530 bytes
The easiest way to output a character, without actually using that character, is to calculate the ASCII value and use the , (character output) command to render it. For example, 49*,@ outputs the dollar character (ASCII 36, 4 * 9). This is rarely the most optimal, though, since most values take more than 3 bytes to calculate.
Another way to generate a number in 3 bytes is to take advantage of the fact that the g (get) command in the first cell of the playfield will generate the ASCII value of g (an empty stack is assumed to be populated with zeros, so it's reading the playfield value at 0,0). Thus g1+,@ gets you h, and g1-,@ gets you f. This obviously works for a range of offsets, and operations other than + and - are also possible. So for example g3/,@ gets you a double quote.
A variation of this, is to precede the g with another command that leaves all zeros on the stack. So you're still reading a value from the playfield at 0,0, but the character being read is now different. This costs one more byte, but gets you access to many more values. For example, 0g1-,@ gets you a forward slash and :g1+,@ gets you a semicolon. Other viable prefixes include *, +, -, >, \ and _. And again note that other operations are possible: >g2*,@ get you a vertical bar.
A further variation is to precede the g with a 1, so you're now no longer reading from 0,0, but from the blank cell at 0,1. In Befunge, empty cells are initialized with spaces by default, so 1g,@ gets you a space, and 1g1+,@ gets you an exclamation mark.
For the digit characters, there's more dubious trick we can use. Instead of trying to output them as characters, we output them as numbers (a small number is easier to generate than its ASCII equivalent). So for example, 11+.@ gives you 2, and in particular note the special cases: .@ for 0, and !.@ for 1. The dubious part of this is that a numeric output in Befunge includes a space after the number, so it's not a pure character output.
Another dubious trick we can use is a variation of the g technique above. Instead of limiting ourselves to Befunge commands for the prefix, we can also technically use any character that isn't a Befunge command. On most interpreters an unrecognised command will be ignored, so the g will end up reading the ASCII value of the preceding character. This enables us to generate most other ASCII values that couldn't otherwise be calculated in 3 bytes. As one example: Qg1+,@ gets you R.
Finally, there are three special cases. A g can't be generated in fewer than 5 bytes, so we have to resort to "f"1+,@. A comma is the most complicated, requiring dynamic modification of the playfield: 0g4-:80p @. We could use a similar technique to avoid the at character, but a more efficient hack is to use the % (modulo) command as the terminator, i.e. 88*,%. When the % is reached there is nothing on the stack, so the modulo calculation generates a division by zero, and on the reference interpreter this will terminate the program.
Below is the full list of programs, one per line.
1g,@
1g1+,@
g3/,@
57*,@
49*,@
1g5+,@
1g6+,@
1g7+,@
58*,@
1g9+,@
0g6-,@
0g5-,@
0g4-:80p @
59*,@
0g2-,@
0g1-,@
.@
!.@
11+.@
21+.@
31+.@
41+.@
51+.@
61+.@
71+.@
81+.@
>g4-,@
:g1+,@
:g2+,@
:g3+,@
:g4+,@
79*,@
88*,%
>g3+,@
>g4+,@
>g5+,@
>g6+,@
>g7+,@
>g8+,@
>g9+,@
89*,@
Hg1+,@
Ig1+,@
Jg1+,@
Kg1+,@
Lg1+,@
Mg1+,@
Ng1+,@
Og1+,@
99*,@
Qg1+,@
\g9-,@
\g8-,@
\g7-,@
\g6-,@
\g5-,@
\g4-,@
\g3-,@
\g2-,@
\g1-,@
_g3-,@
\g1+,@
g9-,@
g8-,@
g7-,@
g6-,@
g5-,@
g4-,@
g3-,@
g2-,@
g1-,@
"f"1+,@
g1+,@
g2+,@
g3+,@
g4+,@
g5+,@
g6+,@
g7+,@
g8+,@
g9+,@
tg3-,@
tg2-,@
tg1-,@
:g2*,@
tg1+,@
tg2+,@
tg3+,@
tg4+,@
tg5+,@
tg6+,@
tg7+,@
>g2*,@
tg9+,@
*g3*,@
Haskell, 1874 1864 1856 1855 1795 1791 1589 bytes, 7 DNPs
Most programs are main=putChar '\xx' or main=putChar '\xxx' where xx/xxx is the ascii code of the char to be printed.
This works for all but 14 chars:
!"#$%& ()*+,-./0123456789:;< >?@AB DEFGHIJKLMNOPQRSTUVWXYZ[ ]^_` bcdefg jkl o q s vwxyz{|}~
' = C \ a hi mn p r tu
However, for the digits 1 7 4 bytes can be saved (thanks to Christian Sievers!):
0 main=print$1-1
1 main=print$3-2
2 main=print$1+1
3 main=print$1+2
...
The 52 programs up to c (code 99) take 18 bytes, the remaining 19 take 19 bytes each.
Partial score: 10*14 + 52*18 + 19*19 = 1437
For 7 of the remaining chars, the following programs work:
main=putChar$'\32'
' main=putStr$pred<$>"("
C main=putStr['\67']
\ main=putChar$pred ']'
h main=putStr['\104']
p main=interact(\_->['\112'])
u main=interact(\_->['\117'])
Partial score: 18 + 22 + 18 + 21 + 19 + 27 + 27 = 152
This leaves 7 DNPs: =aimnrt
Each Haskell program needs to define a main (main=), so that's 5 DNPs. To print to stdOut, putChar, putStr or interact can be used, yielding t and r as further DNPs. (There is also print, however print 'a' prints 'a' and not a - and also contains t and r anyway.)
Haskell also has a chr function which returns the corresponding char given a number, however in order to use it import Data.Char is needed.
Total score: 1437 + 152 = 1589, 7 DNPs
Sesos, 285 bytes (non-competing)
Every program is compiled by using this syntax:
add <decimal-ascii-code>
put
The exception to that is h, which is this code instead (the other one contained an h):
set mask
sub 152
put
Then, compile it to an SBIN file and run (those are all 3 bytes, so the score is calculated as 3 * 94 + 1 * 3 = 285 B.) Note that the SBIN file is the real program, not the pre-assembly syntax shown here.
ASCII constrained x86 Machine Code for DOS, 3104 3101 2913 bytes
Well... It's shorter than Java, I guess...
32 30 bytes for almost all characters, for exceptions see below.
Most of the time it just follows the pattern:
- Do some
xorto get a pointer to the end. subfrom the last 2 words because the opcode forintis not in ASCII.- Get 2 into
AHand the character intoDL. Both arexored because the character itself can't appear in the program and 2 is not a printable ASCII character. - Print the character with
int 21h - Exit with
int 20h
Most of the time, if a character is disallowed, it can be replaced by either twiddling with the data a bit or switching to a different register.
It gets a bit more interesting when you suddenly find yourself unable to subtract or unable to push or pop the only register usable for calculations...
char code
hX'X5B&P[hT!^)7CC)7VX5t#PZ!C!B
! hX'X5B&P[hS ^)7CC)7VX5r"PZ B A
" hX'X5B&P[hS!^)7CC)7VX5q#PZ C B
# hX'X5B&P[hS ^)7CC)7VX5p"PZ B A
$ hX'X5B&P[hS ^)7CC)7VX5w"PZ B A
% hX'X5B&P[hS ^)7CC)7VX5v"PZ B A
& hX#X5B"P[hS ^)7CC)7VX5u"PZ B A
' hX#X5B"P[hS ^)7CC)7VX5t"PZ B A
( hX'X5B&P[hS ^)7CC)7VX5{"PZ B A
) hi'X5B&P[h!!X%BBHP^$!P_17C!?C17C!?hiBX5@@PZ2@2A
* hX'X5B&P[hS ^)7CC)7VX5y"PZ B A
+ hX'X5B&P[hS ^)7CC)7VX5x"PZ B A
, hX'X5B&P[hT ^)7CC)7VX5x"PZ!B!A
- hX'X5B&P[hS ^)7CC)7VX5~"PZ B A
. hX'X5B&P[hS ^)7CC)7VX5}"PZ B A
/ hX'X5B&P[hS ^)7CC)7VX5|"PZ B A
0 hX'X5B&P[hS ^)7CC)7VX5c"PZ B A
1 hX'X5B&P[hS ^)7CC)7VX5b"PZ B A
2 hX'X5B&P[hS ^)7CC)7VX5a"PZ B A
3 hX'X5B&P[hS ^)7CC)7VX5`"PZ B A
4 hX'X5B&P[hS ^)7CC)7VX5g"PZ B A
5 h;'X%[AP[h=S^)7CC)7VX%7"PZ _ ^
6 hX'X5B&P[hS ^)7CC)7VX5e"PZ B A
7 hX'X5B&P[hS _)?CC)?WX5d"PZ B A
8 hX'X5B&P[hS ^)7CC)7VX5k"PZ B A
9 hX'X5B&P[hS ^)7CC)7VX5j"PZ B A
: hX'X5B&P[hS ^)7CC)7VX5i"PZ B A
; hX'X5B&P[hS ^)7CC)7VX5h"PZ B A
< hX'X5B&P[hS ^)7CC)7VX5o"PZ B A
= hX'X5B&P[hS ^)7CC)7VX5n"PZ B A
> hX'X5B&P[hS ^)7CC)7VX5m"PZ B A
? hX'X5B&P[hS ^)7CC)7VX5l"PZ B A
@ hX'X5B&P[h` ^)7CC)7VX5 "PZ-B-A
A hX'X5B&P[h`!^)7CC)7VX5!#PZ-C-B
B h['X5A&P[h`"^)7CC)7VX5" PZ-D-C
C hX'X5B&P_h` ^)5GG)5VX5#"PZ-B-A
D hX'X5B&P[h` ^)7CC)7VX5$"PZ-B-A
E hX'X5B&P[h` ^)7CC)7VX5%"PZ-B-A
F hX'X5B&P[h` ^)7CC)7VX5&"PZ-B-A
G hX'X5B&P[h` ^)7CC)7VX5'"PZ-B-A
H hX'X5B&P[h` ^)7CC)7VX5("PZ-B-A
I hX'X5B&P[h` ^)7CC)7VX5)"PZ-B-A
J hX'X5B&P[h` ^)7CC)7VX5*"PZ-B-A
K hX'X5B&P[h` ^)7CC)7VX5+"PZ-B-A
L hX'X5B&P[h` ^)7CC)7VX5,"PZ-B-A
M hX'X5B&P[h` ^)7CC)7VX5-"PZ-B-A
N hX'X5B&P[h` ^)7CC)7VX5."PZ-B-A
O hX'X5B&P[h` ^)7CC)7VX5/"PZ-B-A
P hj'X5B&`[[[[[[[[h` ^)7CC)7VX50"`ZZZZZZZZ-B-A
Q hX'X5B&P[h` ^)7CC)7VX51"PZ-B-A
R hX'X5B&P[h` ^)7CC)7VX52"PZ-B-A
S hX'X5B&P[h` ^)7CC)7VX53"PZ-B-A
T hX'X5B&P[h` ^)7CC)7VX54"PZ-B-A
U hX'X5B&P[h` ^)7CC)7VX55"PZ-B-A
V hX'X5B&P[h` _)?CC)?WX56"PZ B A
W hX'X5B&P[h` ^)7CC)7VX57"PZ-B-A
X _TYhe'WWWQWWWa5B&P[hSS^)7CC)7CC5_C5 @PZ u t
Y hX'X5B&P[h` ^)7CC)7VX59"PZ-B-A
Z _WTYhzBX5 @Phe'WPWQWWWa5B&P[hSS^)7CC)7X u t
[ hX'X5B&P_h` ^)5GG)5VX5;"PZ-B-A
\ hX'X5B&P[h` ^)7CC)7VX5<"PZ-B-A
] hX'X5B&P[h` ^)7CC)7VX5="PZ-B-A
^ hX'X5B&P[h` _)?CC)?WX5>"PZ-B-A
_ hX'X5B&P[h` ^)7CC)7VX5?"PZ-B-A
` hX'X5B&P[hS ^)7CC)7VX53"PZ B A
a hX'X5B&P[hS ^)7CC)7VX52"PZ B A
b hX'X5B&P[hS ^)7CC)7VX51"PZ B A
c hX'X5B&P[hS ^)7CC)7VX50"PZ B A
d hX'X5B&P[hS ^)7CC)7VX57"PZ B A
e hX'X5B&P[hS ^)7CC)7VX56"PZ B A
f hX'X5B&P[hS ^)7CC)7VX55"PZ B A
g hX'X5B&P[hS ^)7CC)7VX54"PZ B A
h _WWX5b'5B&P[WX5S P^)7CC)7VX5;"PZ B A
i hX'X5B&P[hS ^)7CC)7VX5:"PZ B A
j hX'X5B&P[hS ^)7CC)7VX59"PZ B A
k hX'X5B&P[hS ^)7CC)7VX58"PZ B A
l hX'X5B&P[hS ^)7CC)7VX5?"PZ B A
m hX'X5B&P[hS ^)7CC)7VX5>"PZ B A
n hX'X5B&P[hS ^)7CC)7VX5="PZ B A
o hX'X5B&P[hS ^)7CC)7VX5<"PZ B A
p hX'X5B&P[hS ^)7CC)7VX5#"PZ B A
q hX'X5B&P[hS ^)7CC)7VX5""PZ B A
r hX'X5B&P[hS ^)7CC)7VX5!"PZ B A
s hX'X5B&P[hS ^)7CC)7VX5 "PZ B A
t hX'X5B&P[hS ^)7CC)7VX5'"PZ B A
u hX'X5B&P[hS ^)7CC)7VX5&"PZ B A
v hX'X5B&P[hS ^)7CC)7VX5%"PZ B A
w hX'X5B&P[hS ^)7CC)7VX5$"PZ B A
x hX'X5B&P[hS ^)7CC)7VX5+"PZ B A
y hX'X5B&P[hS ^)7CC)7VX5*"PZ B A
z hX'X5B&P[hS ^)7CC)7VX5)"PZ B A
{ hX'X5B&P[hS ^)7CC)7VX5("PZ B A
| hX'X5B&P[hS ^)7CC)7VX5/"PZ B A
} hX'X5B&P[hS ^)7CC)7VX5."PZ B A
~ hX'X5B&P[hS ^)7CC)7VX5-"PZ B A
GNU sed, 587 578 572 characters
All 95 programs were possible. An input is absolutely required by sed in order to execute the code. Some programs need the extra n flag to avoid a second trailing \n in the output.
Run:
echo | sed -f program_filename
List of all programs with additional details:
Char Program code Size n flag Total size
c\\x20 6 0 6
! c\\x21 6 0 6
" c\\x22 6 0 6
# c\\x23 6 0 6
$ c\\x24 6 0 6
% c\\x25 6 0 6
& c\\x26 6 0 6
' c\\x27 6 0 6
( c\\x28 6 0 6
) c\\x29 6 0 6
* c\\x2A 6 0 6
+ c\\x2B 6 0 6
, c\\x2C 6 0 6
- c\\x2D 6 0 6
. c\\x2E 6 0 6
/ c\\x2F 6 0 6
0 c\\d48 6 0 6
1 = 1 1 2 *
2 c\\d50 6 0 6
3 c\\d51 6 0 6
4 c\\d52 6 0 6
5 c\\d309 7 0 7 *
6 c\\d54 6 0 6
7 c\\d55 6 0 6
8 c\\d56 6 0 6
9 c\\d57 6 0 6
: c\\x3A 6 0 6
; c\\x3B 6 0 6
< c\\x3C 6 0 6
= c\\x3D 6 0 6
> c\\x3E 6 0 6
? c\\x3F 6 0 6
@ c\\x40 6 0 6
A c\\x41 6 0 6
B c\\x42 6 0 6
C c\\x43 6 0 6
D c\\x44 6 0 6
E c\\x45 6 0 6
F c\\x46 6 0 6
G c\\x47 6 0 6
H c\\x48 6 0 6
I c\\x49 6 0 6
J c\\x4A 6 0 6
K c\\x4B 6 0 6
L c\\x4C 6 0 6
M c\\x4D 6 0 6
N c\\x4E 6 0 6
O c\\x4F 6 0 6
P c\\x50 6 0 6
Q c\\x51 6 0 6
R c\\x52 6 0 6
S c\\x53 6 0 6
T c\\x54 6 0 6
U c\\x55 6 0 6
V c\\x56 6 0 6
W c\\x57 6 0 6
X c\\x58 6 0 6
Y c\\x59 6 0 6
Z c\\x5A 6 0 6
[ c\\x5B 6 0 6
\ edc -e92P 9 0 9 *
] c\\x5D 6 0 6
^ c\\x5E 6 0 6
_ c\\x5F 6 0 6
` c\\x60 6 0 6
a c\\x61 6 0 6
b c\\x62 6 0 6
c a\\x63 6 1 7
d c\\x64 6 0 6
e c\\x65 6 0 6
f c\\x66 6 0 6
g c\\x67 6 0 6
h c\\x68 6 0 6
i c\\x69 6 0 6
j c\\x6A 6 0 6
k c\\x6B 6 0 6
l c\\x6C 6 0 6
m c\\x6D 6 0 6
n c\\x6E 6 0 6
o c\\x6F 6 0 6
p c\\x70 6 0 6
q c\\x71 6 0 6
r c\\x72 6 0 6
s c\\x73 6 0 6
t c\\x74 6 0 6
u c\\x75 6 0 6
v c\\x76 6 0 6
w c\\x77 6 0 6
x c\\d120 7 0 7
y c\\x79 6 0 6
z c\\x7A 6 0 6
{ c\\x7B 6 0 6
| c\\x7C 6 0 6
} c\\x7D 6 0 6
~ c\\x7E 6 0 6
Notes:
- all entries are complete programs. Almost every one prints the character based on its ASCII code. Those that deviated are marked with an
*. - to print
1I used the=command, that prints the current input line number (in this case a single newline was the input) - to print
\I called a shell script usinge(the only non pure sed program)
Deadfish, 43 bytes, 85 DNP
o #0
io #1
iio #2
iiio #3
iiso #4
iisio #5
iisiio #6
iiisddo #7
iiisdo #8
iiiso #9
Doesn't fit the definition of programming language, but this IS constant output...
Brainfuck, 1770 1710 1703 1686 bytes
60 bytes saved by Dennis
17 bytes saved by Sp3000
DNP: 46 (.)
>-[-[-<]>>+<]>-.
>-[-[-<]>>+<]>.
>-[-[-<]>>+<]>+.
>-[++>+[<]>+]>.
+[->-[---<]>-]>.
>-[+<[-<]>>++]<.
>+[-->+[<]>-]>-.
>+[-->+[<]>-]>.
>+[-->+[<]>-]>+.
--[>+<++++++]>--.
--[>+<++++++]>-.
-----[[----<]>>-]<.
--[>+<++++++]>+.
+[+[+>]<<++++]>.
+[-[--<]>>--]<.
-[>+<-----]>---.
-[>+<-----]>--.
-[>+<-----]>-.
-[>+<-----]>.
-[>+<-----]>+.
-[>+<-----]>++.
-[>+<-----]>+++.
>-[++>+[+<]>]>-.
>-[++>+[+<]>]>.
>-[++>+[+<]>]>+.
>-[++[+<]>>+<]>.
>+[+[<]>->++]<.
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.
+[-[>+<<]>-]>--.
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.
+[-[>+<<]>-]>.
-[+[>+<<]>+]>.
>+[+[<]>>+<+]>.
--[++>+[<]>+]>.
+[->-[--<]>-]>.
+[->-[--<]>-]>+.
+[->-[--<]>-]>++.
-[+[>---<<]>+]>.
-[>+<-------]>--.
-[>+<-------]>-.
-[>+<-------]>.
-[>+<-------]>+.
-[>+<-------]>++.
>+[+<[-<]>>++]<.
>+++[[-<]>>--]<.
+[+[>>+<+<-]>]>.
-[+>++[++<]>]>-.
-[+>++[++<]>]>.
-[>+<---]>----.
-[>+<---]>---.
-[>+<---]>--.
-[>+<---]>-.
-[>+<---]>.
-[>+<---]>+.
-[>+<---]>++.
-[+[+<]>>+]<.
-[+[+<]>>+]<+.
-[+[+<]>>+]<++.
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.
+[->---[-<]>-]>.
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.
>-->+[+[+<]>>+]<.
>+[+[>+<+<]>]>-.
>+[+[>+<+<]>]>.
+[-[---<]>>-]<-.
+[-[---<]>>-]<.
>-[--[<]>+>-]<.
-[>++<-----]>--.
-[>++<-----]>-.
-[>++<-----]>.
-[>++<-----]>+.
+[->-[<]>--]>-.
+[->-[<]>--]>.
+[->-[<]>--]>+.
>+[++[++>]<<+]>.
>+[++[++>]<<+]>+.
+[->-[<]>+>--]>.
-[>--<-------]>.
>+[+>+[<]>->]<.
>+[+>+[<]>->]<+.
-[+>+++++[<]>+]>.
>+[-->++[<]>-]>.
+[->->-[<]>--]>.
+[->->-[-<]>-]>.
+[->>-[-<+<]>]>.
----[>+++++<--]>.
------[>+++<--]>.
>+[>+[<]>->+]<-.
>+[>+[<]>->+]<.
----[>+++<--]>.
--[>+<--]>----.
--[>+<--]>---.
--[>+<--]>--.
--[>+<--]>-.
All except 43, 45, 60, 62, 91 and 93 are shamelessly stolen from Esolangs.org
Jelly (non-competitive), 406 bytes
32Ọ
33Ọ
34Ọ
35Ọ
36Ọ
37Ọ
38Ọ
39Ọ
40Ọ
41Ọ
42Ọ
43Ọ
44Ọ
45Ọ
46Ọ
47Ọ
48Ọ
49Ọ
50Ọ
51Ọ
52Ọ
49+4Ọ
54Ọ
55Ọ
56Ọ
57Ọ
58Ọ
59Ọ
60Ọ
61Ọ
62Ọ
63Ọ
64Ọ
65Ọ
66Ọ
67Ọ
68Ọ
69Ọ
70Ọ
71Ọ
72Ọ
73Ọ
74Ọ
75Ọ
76Ọ
77Ọ
78Ọ
79Ọ
80Ọ
81Ọ
82Ọ
83Ọ
84Ọ
85Ọ
86Ọ
87Ọ
88Ọ
89Ọ
90Ọ
91Ọ
92Ọ
93Ọ
94Ọ
95Ọ
96Ọ
97Ọ
98Ọ
99Ọ
³Ọ
101Ọ
102Ọ
103Ọ
104Ọ
105Ọ
106Ọ
107Ọ
108Ọ
109Ọ
110Ọ
111Ọ
112Ọ
113Ọ
114Ọ
115Ọ
116Ọ
117Ọ
118Ọ
119Ọ
120Ọ
121Ọ
122Ọ
123Ọ
124Ọ
125Ọ
126Ọ
This prints all characters from 32 - 126. The byte count is calculated with https://mothereff.in/byte-counter.
Matlab, 1238 1224 bytes, 2 DNP
The main pattern is:
disp([<char code> ''])
For digits it's a little shorter:
disp(<sum or difference of two other digits>)
For characters []' it's:
" " -- disp([0,''])
"[" -- disp(char(91))
"]" -- disp(char(93))
"'" -- disp(char(39))
Characters ds from disp are displayed using fprintf (thanks @Stewie Griffin); ip however belong also there, so I'm shifting the string and using eval:
d -- fprintf([100 ''])
i -- eval(['ejtq)(j(*'-1 ''])
s -- fprintf([115 ''])
p -- eval(['ejtq)(q(*'-1 ''])
Both characters () are however necessary for disp or eval, so they are DNP.
For reference the whole list:
char char code code length
32 disp([0 '']) 12
! 33 disp([33 '']) 13
" 34 disp([34 '']) 13
# 35 disp([35 '']) 13
$ 36 disp([36 '']) 13
% 37 disp([37 '']) 13
& 38 disp([38 '']) 13
' 39 disp(char(39)) 14
( 40 DNP
) 41 DNP
* 42 disp([42 '']) 13
+ 43 disp([43 '']) 13
, 44 disp([44 '']) 13
- 45 disp([45 '']) 13
. 46 disp([46 '']) 13
/ 47 disp([47 '']) 13
0 48 disp(1-1) 9
1 49 disp(3-2) 9
2 50 disp(5-3) 9
3 51 disp(7-4) 9
4 52 disp(9-5) 9
5 53 disp(2+3) 9
6 54 disp(3+3) 9
7 55 disp(4+3) 9
8 56 disp(5+3) 9
9 57 disp(6+3) 9
: 58 disp([58 '']) 13
; 59 disp([59 '']) 13
< 60 disp([60 '']) 13
= 61 disp([61 '']) 13
> 62 disp([62 '']) 13
? 63 disp([63 '']) 13
@ 64 disp([64 '']) 13
A 65 disp([65 '']) 13
B 66 disp([66 '']) 13
C 67 disp([67 '']) 13
D 68 disp([68 '']) 13
E 69 disp([69 '']) 13
F 70 disp([70 '']) 13
G 71 disp([71 '']) 13
H 72 disp([72 '']) 13
I 73 disp([73 '']) 13
J 74 disp([74 '']) 13
K 75 disp([75 '']) 13
L 76 disp([76 '']) 13
M 77 disp([77 '']) 13
N 78 disp([78 '']) 13
O 79 disp([79 '']) 13
P 80 disp([80 '']) 13
Q 81 disp([81 '']) 13
R 82 disp([82 '']) 13
S 83 disp([83 '']) 13
T 84 disp([84 '']) 13
U 85 disp([85 '']) 13
V 86 disp([86 '']) 13
W 87 disp([87 '']) 13
X 88 disp([88 '']) 13
Y 89 disp([89 '']) 13
Z 90 disp([90 '']) 13
[ 91 disp(char(91)) 14
\ 92 disp([92 '']) 13
] 93 disp(char(93)) 14
^ 94 disp([94 '']) 13
_ 95 disp([95 '']) 13
` 96 disp([96 '']) 13
a 97 disp([97 '']) 13
b 98 disp([98 '']) 13
c 99 disp([99 '']) 13
d 100 fprintf([100 '']) 17
e 101 disp([101 '']) 14
f 102 disp([102 '']) 14
g 103 disp([103 '']) 14
h 104 disp([104 '']) 14
i 105 eval(['ejtq)(j(*'-1 '']) 24
j 106 disp([106 '']) 14
k 107 disp([107 '']) 14
l 108 disp([108 '']) 14
m 109 disp([109 '']) 14
n 110 disp([110 '']) 14
o 111 disp([111 '']) 14
p 112 eval(['ejtq)(q(*'-1 '']) 24
q 113 disp([113 '']) 14
r 114 disp([114 '']) 14
s 115 fprintf([115,'']) 17
t 116 disp([116 '']) 14
u 117 disp([117 '']) 14
v 118 disp([118 '']) 14
w 119 disp([119 '']) 14
x 120 disp([120 '']) 14
y 121 disp([121 '']) 14
z 122 disp([122 '']) 14
{ 123 disp([123 '']) 14
| 124 disp([124 '']) 14
} 125 disp([125 '']) 14
~ 126 disp([126 '']) 14
Java 8, 6798 6582 6577 bytes
sigh
This is basically a port of my Python 2 answer, but with all the boilerplate that comes with writing a full program in Java.
Now without any DNPs at all! Thanks, Kevin Cruijssen!
Most of the programs have the form interface A{static void main(String[]a){System.out.print("\<octal char code>");}}, except:
- space →
interface\tA{static\tvoid\tmain(String[]a){System.out.print("\40");}}(but with the\ts replaced by raw tabs) "→interface A{static void main(String[]a){System.out.print('\42');}}(→interface A{static void main\u0028String[]a){System.out.print\u0028"\50");}})→interface A{static void main(String[]a\u0029{System.out.print("\51"\u0029;}}.→interface A{static void main(String[]a){System\u002Eout\u002Eprint("\56");}}0→interface A{static void main(String[]a){System.out.print(1-1);}}1→interface A{static void main(String[]a){System.out.print(3-2);}}2→interface A{static void main(String[]a){System.out.print(3-1);}}3→interface A{static void main(String[]a){System.out.print(4-1);}}4→interface A{static void main(String[]a){System.out.print(5-1);}}5→interface A{static void main(String[]a){System.out.print(6-1);}}6→interface A{static void main(String[]a){System.out.print(7-1);}}7→interface A{static void main(String[]a){System.out.print(8-1);}}8→interface A{static void main(String[]a){System.out.print(9-1);}}9→interface A{static void main(String[]a){System.out.print(8+1);}};→interface A{static void main(String[]a){System.out.print("\73")\u003B}}A→interface B{static void main(String[]a){System.out.print("\101");}}S→interface A{static void main(\u0053tring[]a){\u0053ystem.out.print("\123");}}[→interface A{static void main(String...a){System.out.print("\133");}}\→interface A{static void main(String[]a){System.out.print((char)92);}}]→interface A{static void main(String...a){System.out.print("\135");}}a→interf\u0061ce A{st\u0061tic void m\u0061in(String[]b){System.out.print("\141");}}c→interfa\u0063e A{stati\u0063 void main(String[]a){System.out.print("\143");}}d→interface A{static voi\u0064 main(String[]a){System.out.print("\144");}}e→class A{public static void main(String[]a){Syst\u0065m.out.print("\145");}}f→class A{public static void main(String[]a){System.out.print("\146");}}g→interface A{static void main(Strin\u0067[]a){System.out.print("\147");}}// \u0067i→\u0069nterface A{stat\u0069c vo\u0069d ma\u0069n(Str\u0069ng[]a){System.out.pr\u0069nt("\151");}}m→interface A{static void \u006Dain(String[]a){Syste\u006D.out.print("\155");}}n→class A{public static void mai\u006E(Stri\u006Eg[]a){System.out.pri\u006Et("\156");}}o→interface A{static v\u006Fid main(String[]a){System.\u006Fut.print("\157");}}p→interface A{static void main(String[]a){System.out.\u0070rint("\160");}}r→class A{public static void main(St\u0072ing[]a){System.out.p\u0072int("\162");}}s→interface A{\u0073tatic void main(String[]a){Sy\u0073tem.out.print("\163");}}t→class A{public s\u0074a\u0074ic void main(S\u0074ring[]a){Sys\u0074em.ou\u0074.prin\u0074("\164");}}u→interface A{static void main(String[]a){System.console().printf("%c",117);}}v→interface A{static \u0076oid main(String[]a){System.out.print("\166");}}y→interface A{static void main(String[]a){S\u0079stem.out.print("\171");}}{→interface A\u007Bstatic void main(String[]a)\u007BSystem.out.print("\173");}}}→interface A{static void main(String[]a){System.out.print("\175");\u007D\u007D
Phew
The Java compiler processes Unicode escapes like \u007B before doing any other processing, which makes it possible to write code which uses unicode escapes in identifiers and even keywords. So, to write a program that doesn't use a character present in the boilerplate, we simply substitute it with it unicode escape.
For reference and ease of testing, here's the full list of programs, newline-separated and with the raw tabs replaced by four spaces:
interface A{static void main(String[]a){System.out.print("\40");}}
interface A{static void main(String[]a){System.out.print("\41");}}
interface A{static void main(String[]a){System.out.print('\42');}}
interface A{static void main(String[]a){System.out.print("\43");}}
interface A{static void main(String[]a){System.out.print("\44");}}
interface A{static void main(String[]a){System.out.print("\45");}}
interface A{static void main(String[]a){System.out.print("\46");}}
interface A{static void main(String[]a){System.out.print("\47");}}
interface A{static void main\u0028String[]a){System.out.print\u0028"\50");}}
interface A{static void main(String[]a\u0029{System.out.print("\51"\u0029;}}
interface A{static void main(String[]a){System.out.print("\52");}}
interface A{static void main(String[]a){System.out.print("\53");}}
interface A{static void main(String[]a){System.out.print("\54");}}
interface A{static void main(String[]a){System.out.print("\55");}}
interface A{static void main(String[]a){System\u002Eout\u002Eprint("\56");}}
interface A{static void main(String[]a){System.out.print("\57");}}
interface A{static void main(String[]a){System.out.print(1-1);}}
interface A{static void main(String[]a){System.out.print(3-2);}}
interface A{static void main(String[]a){System.out.print(3-1);}}
interface A{static void main(String[]a){System.out.print(4-1);}}
interface A{static void main(String[]a){System.out.print(5-1);}}
interface A{static void main(String[]a){System.out.print(6-1);}}
interface A{static void main(String[]a){System.out.print(7-1);}}
interface A{static void main(String[]a){System.out.print(8-1);}}
interface A{static void main(String[]a){System.out.print(9-1);}}
interface A{static void main(String[]a){System.out.print(8+1);}}
interface A{static void main(String[]a){System.out.print("\72");}}
interface A{static void main(String[]a){System.out.print("\73")\u003B}}
interface A{static void main(String[]a){System.out.print("\74");}}
interface A{static void main(String[]a){System.out.print("\75");}}
interface A{static void main(String[]a){System.out.print("\76");}}
interface A{static void main(String[]a){System.out.print("\77");}}
interface A{static void main(String[]a){System.out.print("\100");}}
interface B{static void main(String[]a){System.out.print("\101");}}
interface A{static void main(String[]a){System.out.print("\102");}}
interface A{static void main(String[]a){System.out.print("\103");}}
interface A{static void main(String[]a){System.out.print("\104");}}
interface A{static void main(String[]a){System.out.print("\105");}}
interface A{static void main(String[]a){System.out.print("\106");}}
interface A{static void main(String[]a){System.out.print("\107");}}
interface A{static void main(String[]a){System.out.print("\110");}}
interface A{static void main(String[]a){System.out.print("\111");}}
interface A{static void main(String[]a){System.out.print("\112");}}
interface A{static void main(String[]a){System.out.print("\113");}}
interface A{static void main(String[]a){System.out.print("\114");}}
interface A{static void main(String[]a){System.out.print("\115");}}
interface A{static void main(String[]a){System.out.print("\116");}}
interface A{static void main(String[]a){System.out.print("\117");}}
interface A{static void main(String[]a){System.out.print("\120");}}
interface A{static void main(String[]a){System.out.print("\121");}}
interface A{static void main(String[]a){System.out.print("\122");}}
interface A{static void main(\u0053tring[]a){\u0053ystem.out.print("\123");}}
interface A{static void main(String[]a){System.out.print("\124");}}
interface A{static void main(String[]a){System.out.print("\125");}}
interface A{static void main(String[]a){System.out.print("\126");}}
interface A{static void main(String[]a){System.out.print("\127");}}
interface A{static void main(String[]a){System.out.print("\130");}}
interface A{static void main(String[]a){System.out.print("\131");}}
interface A{static void main(String[]a){System.out.print("\132");}}
interface A{static void main(String...a){System.out.print("\133");}}
interface A{static void main(String[]a){System.out.print((char)92);}}
interface A{static void main(String...a){System.out.print("\135");}}
interface A{static void main(String[]a){System.out.print("\136");}}
interface A{static void main(String[]a){System.out.print("\137");}}
interface A{static void main(String[]a){System.out.print("\140");}}
interf\u0061ce A{st\u0061tic void m\u0061in(String[]b){System.out.print("\141");}}
interface A{static void main(String[]a){System.out.print("\142");}}
interfa\u0063e A{stati\u0063 void main(String[]a){System.out.print("\143");}}
interface A{static voi\u0064 main(String[]a){System.out.print("\144");}}
class A{public static void main(String[]a){Syst\u0065m.out.print("\145");}}
class A{public static void main(String[]a){System.out.print("\146");}}
interface A{static void main(Strin\u0067[]a){System.out.print("\147");}}
interface A{static void main(String[]a){System.out.print("\150");}}
\u0069nterface A{stat\u0069c vo\u0069d ma\u0069n(Str\u0069ng[]a){System.out.pr\u0069nt("\151");}}
interface A{static void main(String[]a){System.out.print("\152");}}
interface A{static void main(String[]a){System.out.print("\153");}}
interface A{static void main(String[]a){System.out.print("\154");}}
interface A{static void \u006Dain(String[]a){Syste\u006D.out.print("\155");}}
class A{public static void mai\u006E(Stri\u006Eg[]a){System.out.print("\156");}}
interface A{static v\u006Fid main(String[]a){System.\u006Fut.print("\157");}}
interface A{static void main(String[]a){System.out.\u0070rint("\160");}}
interface A{static void main(String[]a){System.out.print("\161");}}
class A{public static void main(St\u0072ing[]a){System.out.p\u0072int("\162");}}
interface A{\u0073tatic void main(String[]a){Sy\u0073tem.out.print("\163");}}
class A{public s\u0074a\u0074ic void main(S\u0074ring[]a){Sys\u0074em.ou\u0074.prin\u0074("\164");}}
interface A{static void main(String[]a){System.console().printf("%c",117);}}
interface A{static \u0076oid main(String[]a){System.out.print("\166");}}
interface A{static void main(String[]a){System.out.print("\167");}}
interface A{static void main(String[]a){System.out.print("\170");}}
interface A{static void main(String[]a){S\u0079stem.out.print("\171");}}
interface A{static void main(String[]a){System.out.print("\172");}}
interface A\u007Bstatic void main(String[]a)\u007BSystem.out.print("\173");}}
interface A{static void main(String[]a){System.out.print("\174");}}
interface A{static void main(String[]a){System.out.print("\175");\u007D\u007D
interface A{static void main(String[]a){System.out.print("\176");}}
Note that the program for u makes use of System.console(), which will return null (and thus cause the code to throw a NullPointerException) if you call it from anything other than your OS' native terminal (cmd on Windows, and, I assume, bash on Linux/OSX).
To test, make a new directory and put the above code in a file named printables in that directory. Then, run the following Bash script:
#!/bin/bash
split -l 1 printables
for i in x*; do
mkdir z$i
mv $i z$i/A.java
done
mv zxbh/A.java zxbh/B.java
for i in zx*; do
javac $i/[AB].java
if ! java -cp $i A 2> /dev/null; then
java -cp $i B
fi
done
rm -r zx*
The above script will put each line of printables into its own directory, name them all A.java (except for the file which prints A, which is renamed to B.java), compile each file, run them, then delete the evidence. It should take about ten seconds for the printable ASCII characters to start appearing in your shell.
If you're on Windows, instead run the following Batch file:
@echo off
setlocal enabledelayedexpansion
set i=0
for /F "tokens=*" %%L in (printables) do (
set file=A.java
if "%i%" == "33" (set file=B.java)
echo %%L>"%file%"
javac "%file%"
java -cp . A
if not errorlevel 0 (java -cp . B)
set /A i=%i% + 1
)
del *.java
del *.class
This batch file takes a slightly different approach; instead of pre-splitting the lines, it processes the file line-by-line and compiles and runs each program in turn. Again, it deletes the evidence after it finishes.
Saved countless bytes + the 1 DNP thanks to Kevin Cruijssen!
dc, 314 287 286 bytes
Every character save for '5' and 'P' can be output via xxP where xx is the ASCII code point. 32P, 65P, 112P, etc. For 32-99, excepting 53 ('5') and 80 ('P'), that's 198 bytes. 100-126 gives us an additional 108 bytes, subtotal 306 bytes. Thanks to @Deliot for making me realize I'm sane... dc reserves the words/digits A-F for base >10 input, and doesn't really do any checks relating to inputting a digit beyond the scope of the input radix. This doesn't seem to work with cygwin's dc, but does with Darwin's and Ubuntu's: dc still interprets the number as decimal, but replaces A-F digits with 10-15 including a carry. So A0 becomes 100, AF becomes 115, etc. This adds 81 bytes for a subtotal of 279.
xxa converts a value on the stack to a single character, and n will print it, so that takes care of 'P' - 80an with an additional 4 bytes, subtotal 310 283.
For '5' we can rely on UCHAR_MAX overflow. 53+256=309, which has no 5s in it, so use the same A-F behavior with 309P it is4DP (thanks @Joe), add 4 3 bytes for a total of 314 287 286.
All of it:
32P
33P
34P
35P
36P
37P
38P
39P
40P
41P
42P
43P
44P
45P
46P
47P
48P
49P
50P
51P
52P
4DP
54P
55P
56P
57P
58P
59P
60P
61P
62P
63P
64P
65P
66P
67P
68P
69P
70P
71P
72P
73P
74P
75P
76P
77P
78P
79P
80an
81P
82P
83P
84P
85P
86P
87P
88P
89P
90P
91P
92P
93P
94P
95P
96P
97P
98P
99P
A0P
A1P
A2P
A3P
A4P
A5P
A6P
A7P
A8P
A9P
B0P
B1P
B2P
B3P
B4P
B5P
B6P
B7P
B8P
B9P
C0P
C1P
C2P
C3P
C4P
C5P
C6P
FerNANDo, 1786 (19x94) bytes (1 DNP)
Did not program (space).
The programs follow a pattern. The first one (!) is as follows:
b a
a a b a a a a b
This sets b to 1 (a is by default 0), and then outputs the ASCII character represented by the binary 00100001 (constructed using a and b). This can be repeated for any ASCII character using the same length of source code. To make the programs that print a and b, use the same code but name the variables c and d instead:
a:
d c
c d d c c c c d
b:
d c
c d d c c c d c
Perl 6: 921 bytes
Translation of the Python solution.
Each program has the form say "\x<hex escape code>", except:
s→put "\x73"a→put "\x61"y→put "\x79"→"\x20".say"→say chr 34\→say chr 92x→say chr 1200→say 1-11→say 3-22to9→say <n minus one>+1
For reference and ease of testing, here's the full list of programs, newline-separated.
"\x20".say
say "\x21"
say chr 34
say "\x23"
say "\x24"
say "\x25"
say "\x26"
say "\x27"
say "\x28"
say "\x29"
say "\x2A"
say "\x2B"
say "\x2C"
say "\x2D"
say "\x2E"
say "\x2F"
say 1-1
say 3-2
say 1+1
say 2+1
say 3+1
say 4+1
say 5+1
say 6+1
say 7+1
say 8+1
say "\x3A"
say "\x3B"
say "\x3C"
say "\x3D"
say "\x3E"
say "\x3F"
say "\x40"
say "\x41"
say "\x42"
say "\x43"
say "\x44"
say "\x45"
say "\x46"
say "\x47"
say "\x48"
say "\x49"
say "\x4A"
say "\x4B"
say "\x4C"
say "\x4D"
say "\x4E"
say "\x4F"
say "\x50"
say "\x51"
say "\x52"
say "\x53"
say "\x54"
say "\x55"
say "\x56"
say "\x57"
say "\x58"
say "\x59"
say "\x5A"
say "\x5B"
say chr 92
say "\x5D"
say "\x5E"
say "\x5F"
say "\x60"
put "\x61"
say "\x62"
say "\x63"
say "\x64"
say "\x65"
say "\x66"
say "\x67"
say "\x68"
say "\x69"
say "\x6A"
say "\x6B"
say "\x6C"
say "\x6D"
say "\x6E"
say "\x6F"
say "\x70"
say "\x71"
say "\x72"
put "\x73"
say "\x74"
say "\x75"
say "\x76"
say "\x77"
say chr 120
put "\x79"
say "\x7A"
say "\x7B"
say "\x7C"
say "\x7D"
say "\x7E"
Here's the code I used to test the above listing, and count the score:
#!/usr/bin/env perl6
my $file = 'print_ascii_characters.p6';
my @expected = ' ' .. '~';
my @code = $file.IO.lines;
my $code = @code.join: ';';
my @got = (run 'perl6', '-e', $code, :out).out.lines.map: |*.comb;
given +@expected, +@got, +@code -> ($e, $g, $c) {
say "WRONG COUNT: Expected $e / output $g / source $c" and exit if not $e == $g == $c;
}
for @expected Z @got -> ($e, $g) {
say "WRONG OUTPUT: Expected {$e.perl}, got {$g.perl}" and exit if $e ne $g;
}
for @expected Z @code -> ($char, $code) {
say "COLLISION: {$char.perl} contained in {$code.perl}" if $code.match($char);
}
say "SCORE: ", @code.map(*.chars).sum;
Reng, 564 560 bytes, non-competing
Reng uses ISO-8859-1, and in this submission, it uses those characters.
Wo~
Xo~
Yo~
Zo~
6²o~
KH+o~
KI+o~
KJ+o~
K2*o~
KL+o~
KM+o~
43¹o~
44¹o~
45¹o~
46¹o~
47¹o~
n~
7²o~
1|~n+
51¹o~
2|~n+
41+n~
3|~n+
55¹o~
4|~n+
57¹o~
58¹o~
59¹o~
60¹o~
61¹o~
62¹o~
63¹o~
8²o~
65¹o~
66¹o~
67¹o~
68¹o~
69¹o~
70¹o~
71¹o~
72¹o~
73¹o~
74¹o~
75¹o~
76¹o~
77¹o~
78¹o~
79¹o~
80¹o~
9²o~
82¹o~
83¹o~
84¹o~
85¹o~
86¹o~
87¹o~
88¹o~
89¹o~
90¹o~
91¹o~
92¹o~
93¹o~
94¹o~
95¹o~
96¹o~
97¹o~
98¹o~
99¹o~
A0¹o~
A1¹o~
A2¹o~
A3¹o~
A4¹o~
A5¹o~
A6¹o~
A7¹o~
A8¹o~
A9¹o~
1A¹o~
B1¹:70g ~
B2¹o~
B3¹o~
B4¹o~
B5¹o~
B6¹o~
B7¹o~
B8¹o~
B9¹o~
C0¹o~
B²o~
C2¹o~
C3¹o~
C4¹o~
C5¹o~
C6¹:00go
All of these are mostly writing out the hex code of the character (¹ is "manhattan addition", e.g. digit concatenation), but here are some highlights:
C6¹:00go
This prints ~:
C6¹:00go
C6¹ push 126 (C = 12, 6 = 6, 12 +M 6 = 126)
: duplicate
00g place in first slot
o output tilde
(modified code, it wraps around)
~6¹:00go
~ terminate the program
This prints o:
B1¹:70g ~
B1¹ push 111 (B = 11, 1 = 1, B +M 1 = 111)
: duplicate
70g place at seventh character
o (this was just placed) - output
~ terminate
Retina, 712 bytes, 2 DNPs
This was a collaborative effort with FryAmTheEggman.
There are several classes of solutions. For most characters from space to ^, we use a program of the following form:
_
T`w`p
The character on the second line iterates through the ranges _0-9A-Za-z while the rest remains unchanged. This turns the empty input into that character and then replaces it with the printable ASCII character (represented by p) at the corresponding position. Each of these programs is 8 bytes long.
Within this range, there are only a few exceptions. Most importantly the digits can be shortened:
- 0:
x(counts the number ofxs in the empty input) - 1:
(weehoo, empty program; counts the number of empty matches in the empty input) 2: now we turn the input into a single character, before counting empty strings:
13: same thing but we turn the input into two characters:
114: you get the idea...
1115 - 9: plot twist... we use character repetition to avoid the second line getting any longer:
4$*...
8$*
The other exception is that T is a DNP: we don't think it's possible to generate a non-digit character without it appearing in the source code if transliteration stages can't be used.
On to the remaining characters. To print _ we use a similar program as the general solution above:
0
T`0`w
Making use of the fact that w starts with _.
Next, ` is the second DNP, because transliteration stages require those as well.
Then most of the lower-case letters are printed with something like this (which prints a):
_
T`w`l
Again, the character on the second line increments through _0-9A-O. Here, we just need to watch out for l and w, which we can print with the following programs, respectively:
P
T`p`w
6
T`p`l
Finally, only {|}~ are left, which require 9 bytes each. Here, we use the transliteration stage to increment the character that precedes them. E.g. ~ can be printed with:
}
T`_p`p
Fission, 455 bytes
Most programs are 5 bytes long and of the following form:
R'!_O
! R'"_O
" R'#_O
...
These work simply by creating a right-going atom with R, setting its mass to a character one greater than the one we want print with 'X, decrementing it with _ and then printing it with O, which also destroys the atom and terminates the program.
There are a few exceptions. ' requires a two-line program:
+> vLR+
O/;
And there are the following exceptions using single-line programs:
C R'B+O
K R'J+O
O R'P_!*
Q R'P+O
R O_S'L
T R'S+O
` Ra_O
a Rb_O
b Rc_O
...
y Rz_O
z Ry+O
{ Rz+O
~ R'}+O
Explanation for these (not in order):
Lower-case letters actually set the atom's mass to their character code without requiring the use of
', so we can actually save a byte on all lower-case letters and the two adjacent characters:` Ra_O a Rb_O b Rc_O ... y Rz_O z Ry+O { Rz+OThat's 4 bytes each.
- For
~, we can't use the next larger character, so we use the previous one and increment it:R'}+O. We also do this for_to avoid using it in the code, i.e.R'^+O. We also do this for each ofCKQT, because otherwise the correspondingDLRUin the code would create another, unwanted atom. These are still 5 bytes. - For
O, we can't useOfor printing. Hence we use!. But this doesn't destroy the atom, so we need to terminate the program explicitly:R'P_!*. That's 6 bytes. - For
R, we start with a left-going atom and reverse the code:O_S'L. Still 5 bytes. Finally, there's
'which is by far the trickiest one. The shortest I've found is 11 bytes:+> vLR+ O/;RandLboth create an atom (initially with mass 1). The right-going one's mass is incremented twice to3(note that the grid wraps around) and stored inside the fission reactor>. The fission reactor can now be used for division by 3 (as opposed to the default of 2).Meanwhile, the left-going atom gets its value set to
v(118). When it now hits the Fission reactor, it is split into two parts, one with mass39(') going south and one with mass79(O) going north. Since the grid wraps around, they both hit the;. TheOatom is deflected onto the;where it is destroyed. The'is deflected onto theOwhich (as usual) prints the character and destroys the atom.
Python 2, 1075 1065 1043 1040 1039 bytes
Each program has the form print'\<octal char code>', except:
'→print"\47"0through8→print~-<N+1>9→print-~8\→print'%c'%92i→exec'pr\151nt"\151"'n→exec'pri\156t"\156"'p→exec'\160rint"\160"'r→exec'p\162int"\162"'t→exec'prin\164"\164"'
For reference and ease of testing, here's the full list of programs, newline-separated.
print'\40'
print'\41'
print'\42'
print'\43'
print'\44'
print'\45'
print'\46'
print"\47"
print'\50'
print'\51'
print'\52'
print'\53'
print'\54'
print'\55'
print'\56'
print'\57'
print~-1
print~-2
print~-3
print~-4
print~-5
print~-6
print~-7
print~-8
print~-9
print-~8
print'\72'
print'\73'
print'\74'
print'\75'
print'\76'
print'\77'
print'\100'
print'\101'
print'\102'
print'\103'
print'\104'
print'\105'
print'\106'
print'\107'
print'\110'
print'\111'
print'\112'
print'\113'
print'\114'
print'\115'
print'\116'
print'\117'
print'\120'
print'\121'
print'\122'
print'\123'
print'\124'
print'\125'
print'\126'
print'\127'
print'\130'
print'\131'
print'\132'
print'\133'
print'%c'%92
print'\135'
print'\136'
print'\137'
print'\140'
print'\141'
print'\142'
print'\143'
print'\144'
print'\145'
print'\146'
print'\147'
print'\150'
exec'pr\151nt"\151"'
print'\152'
print'\153'
print'\154'
print'\155'
exec'pri\156t"\156"'
print'\157'
exec'\160rint"\160"'
print'\161'
exec'p\162int"\162"'
print'\163'
exec'prin\164"\164"'
print'\165'
print'\166'
print'\167'
print'\170'
print'\171'
print'\172'
print'\173'
print'\174'
print'\175'
print'\176'
To test:
$ python printables.py | sed ':a;N;$!ba;s/\n//g'
!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~
-1 bytes thanks to @Sp3000!
Fourier, 306 bytes, 1 DNP
Pretty much all of the programs follow the pattern na where n is the character code of each of the characters. For example:
! 33a
" 34a
# 35a
$ 36a
% 37a
& 38a
' 39a
So I'll just list the exceptions:
0 (Zero)
Since the accumulator is preset to zero, we can display this using a single character:
o
1
Similar to zero, this increments the accumulator to get 1.
^o
5
The ASCII code for 5 is 53, so I had to work around this:
6vo
a
Due to a being the character output function, there is no other way to produce the character a, so this my only DID NOT PROGRAM.
See all of the programs here
Whitespace, 1643 bytes, 1 DNP
17 bytes for the characters [33-63] and 18 bytes for characters [64-126]
In Whitespace this is straight forward, because printable characters (except space) don't have any meaning anyway:
[SPACE][SPACE][SPACE][TAB][SPACE][SPACE][SPACE][SPACE][TAB][LF]
[TAB][LF]
[SPACE][SPACE][LF]
[LF]
[LF]
The program above prints a '!' (100001b).
Change [TAB][SPACE][SPACE][SPACE][SPACE][TAB] in the first line to whichever character you like.
It's not possible to print a space without using a space, because printing anything always starts with [TAB][LF][SPACE]
Marbelous, 220 bytes
For a character that is not a digit, it is just the two uppercase hex digits of the character code. For example, the following program outputs A:
41
For a digit that is not 3, replace 2F in the following code by the uppercase hex digits of the character code - 1:
2F
++
For 3:
66
>>
Total score: 2*85 + 5*10 = 220.
My first try was Bubblegum and it didn't work for characters before ?...
Hexagony, 376 373 bytes, 1 DNP
Thanks to FryAmTheEggman for saving 3 bytes.
Almost all programs have the same form:
P0;@
! P1;@
" P2;@
...
| Y2;@
} Y3;@
~ Y4;@
There are a few exceptions though:
- It's impossible to print
;without using;, hence 1 DNP. - To print
@, we cannot use@to terminate the program. Instead we use eitherS2;:orS3;%. This terminates with a division-by-zero error, but that error is not visible on STDOUT. So this is still four bytes. - There is one clash for
Uwhich would requireU3;@. There are several ways to fix this, including switching to lower-case, i.e.n9;@, or using increment or decrement, i.e.T);@orV(;@. In any case it's still four bytes. - Memory edges are initialised to
0, and!prints an integer value, so we can get0and1with!@and)!@, respectively, saving 3 bytes.
As for how the <letter><digit>;@ programs work: the hexagonal layout of a program of the form 1234 is always
1 2
3 4 .
. .
Since none of the programs contain any commands that redirect control flow, these are simply linear programs that are executed in order.
In every case, the letter at the beginning of the code sets the current memory edge to its character code. E.g. in the program P1;@, the P sets the value 80. Then the digit multiplies this value by 10 and adds itself (i.e. the digit is appended to the current value). That gives 801 in the example above. Finally, ; prints this value by taking it modulo 256 and using it as a byte value. In this case 801 % 256 = 33 and a ! is printed.
Actually, 383 382 381 bytes
1 byte thanks to Mego.
For easy reference, the first column is the character code, the second column is the character, and the third column is the code.
The code for 0 is a single space.
032 :32c
033 ! HN
034 " 9Fc
035 # :35c
036 $ :36c
037 % :37c
038 & :38c
039 ' :39c
040 ( :40c
041 ) 9R$N
042 * :42c
043 + :43c
044 , :44c
045 - :45c
046 . :46c
047 / :47c
048 0
049 1 0Y
050 2 0P
051 3 1P
052 4 3u
053 5 2P
054 6 3!
055 7 3P
056 8 6F
057 9 NF
058 : 9P;+c
059 ; :59c
060 < :60c
061 = :61c
062 > :62c
063 ? :63c
064 @ :64c
065 A :65c
066 B :66c
067 C :67c
068 D :68c
069 E :69c
070 F :70c
071 G :71c
072 H :72c
073 I :73c
074 J :74c
075 K :75c
076 L :76c
077 M :77c
078 N :78c
079 O :79c
080 P :80c
081 Q :81c
082 R :82c
083 S :83c
084 T :84c
085 U :85c
086 V :86c
087 W :87c
088 X :88c
089 Y :89c
090 Z :90c
091 [ k$F
092 \ :92c
093 ] k$N
094 ^ :94c
095 _ :95c
096 ` :96c
097 a :97c
098 b :98c
099 c :12#"%x"%
100 d :100c
101 e :101c
102 f :102c
103 g :103c
104 h :104c
105 i :105c
106 j :106c
107 k :107c
108 l :108c
109 m :109c
110 n :110c
111 o :111c
112 p :112c
113 q 9PPc
114 r 9R$F
115 s :115c
116 t :116c
117 u :117c
118 v :118c
119 w 5!Dc
120 x 5!c
121 y 5!uc
122 z :122c
123 { :123c
124 | :124c
125 } :125c
126 ~ :126c
Golfing suggestions are welcome.
Dyalog APL, 527 522 bytes
(non-competing because APL cannot really be written using ASCII only)
Most are in the format nn⊃⎕AV or nnn⊃⎕AV, the exceptions being:
⊃'' ⍝ space: extract one char from an empty string
⎕THIS ⍝ hash: this namespace
⊃1↓⍕÷2 ⍝ period: the first char after stripping one char from 1÷2, i.e. 0.5
⊃⍬ ⍝ zero: extract one number from an empty numeric list
≢# ⍝ one: tally the root namespace
⍴⍬⍬ ⍝ two: count two empty lists
⎕WX ⍝ three: default "Window Expose" setting
×⍨2 ⍝ four: 2×2
6-1 ⍝ five: 6-1
!3 ⍝ six: 3!
6+1 ⍝ seven: 6+1
2*3 ⍝ eight: 2³
3*2 ⍝ nine: 3²
⊃⎕a ⍝ A: first character (Dyalog system names are case insensitive)
2⊃⎕A ⍝
⋮ ⍝ B-Y: n'th character
25⊃⎕A ⍝
⊃⌽⎕A ⍝ Z: last character
Here is the entire list:
⊃''
205⊃⎕AV
216⊃⎕AV
⎕THIS
62⊃⎕AV
13⊃⎕AV
219⊃⎕AV
14⊃⎕AV
186⊃⎕AV
249⊃⎕AV
181⊃⎕AV
170⊃⎕AV
195⊃⎕AV
169⊃⎕AV
⊃1↓⍕÷2
157⊃⎕AV
⊃⍬
≢#
⍴⍬ ⍬
⎕WX
×⍨2
6-1
!3
6+1
2*3
3*2
241⊃⎕AV
194⊃⎕AV
161⊃⎕AV
163⊃⎕AV
165⊃⎕AV
173⊃⎕AV
232⊃⎕AV
⊃⎕a
2⊃⎕A
3⊃⎕A
4⊃⎕A
5⊃⎕A
6⊃⎕A
7⊃⎕A
8⊃⎕A
9⊃⎕A
10⊃⎕A
11⊃⎕A
12⊃⎕A
13⊃⎕A
14⊃⎕A
15⊃⎕A
16⊃⎕A
17⊃⎕A
18⊃⎕A
19⊃⎕A
20⊃⎕A
21⊃⎕A
22⊃⎕A
23⊃⎕A
24⊃⎕A
25⊃⎕A
26⊃⎕A
156⊃⎕AV
159⊃⎕AV
250⊃⎕AV
236⊃⎕AV
17⊃⎕AV
238⊃⎕AV
18⊃⎕AV
19⊃⎕AV
20⊃⎕AV
21⊃⎕AV
22⊃⎕AV
23⊃⎕AV
24⊃⎕AV
25⊃⎕AV
26⊃⎕AV
27⊃⎕AV
28⊃⎕AV
29⊃⎕AV
30⊃⎕AV
31⊃⎕AV
32⊃⎕AV
33⊃⎕AV
34⊃⎕AV
35⊃⎕AV
36⊃⎕AV
37⊃⎕AV
38⊃⎕AV
39⊃⎕AV
40⊃⎕AV
41⊃⎕AV
42⊃⎕AV
43⊃⎕AV
124⊃⎕AV
193⊃⎕AV
126⊃⎕AV
176⊃⎕AV
Groovy, 1019 bytes
I had a different Groovy solution written up (see below), but after I submitted it I did a bit more digging into character escapes, hoping to find a way of shortening the program more, and discovered that Groovy has an octal character escape that I did not know of. This significantly simplifies the code, to the point that it unfortunately removes the need for almost all of the quirky workarounds I had come up with.
It also looks almost identical to Copper's Python 2 solution, to the point where it basically looks like I plagiarized their work. Ugh.
Each program has the form print'\<octal value>', except:
p,r,i,n,t→'print''\<octal value>'(but with the matching letter of "print" also replaced with the octal value)0-9→print~-<next int>
Here is the full list of programs by character.
print'\40'
! print'\41'
" print'\42'
# print'\43'
$ print'\44'
% print'\45'
& print'\46'
' print'\47'
( print'\50'
) print'\51'
* print'\52'
+ print'\53'
, print'\54'
- print'\55'
. print'\56'
/ print'\57'
0 print~-1
1 print~-2
2 print~-3
3 print~-4
4 print~-5
5 print~-6
6 print~-7
7 print~-8
8 print~-9
9 print~-10
: print'\72'
; print'\73'
< print'\74'
= print'\75'
> print'\76'
? print'\77'
@ print'\100'
A print'\101'
B print'\102'
C print'\103'
D print'\104'
E print'\105'
F print'\106'
G print'\107'
H print'\110'
I print'\111'
J print'\112'
K print'\113'
L print'\114'
M print'\115'
N print'\116'
O print'\117'
P print'\120'
Q print'\121'
R print'\122'
S print'\123'
T print'\124'
U print'\125'
V print'\126'
W print'\127'
X print'\130'
Y print'\131'
Z print'\132'
[ print'\133'
\ print'\134'
] print'\135'
^ print'\136'
_ print'\137'
` print'\140'
a print'\141'
b print'\142'
c print'\143'
d print'\144'
e print'\145'
f print'\146'
g print'\147'
h print'\150'
i 'pr\151nt''\151'
j print'\152'
k print'\153'
l print'\154'
m print'\155'
n 'pri\156t''\156'
o print'\157'
p '\160rint''\160'
q print'\161'
r 'p\162int''\162'
s print'\163'
t 'prin\164''\164'
u print'\165'
v print'\166'
w print'\167'
x print'\170'
y print'\171'
z print'\172'
{ print'\173'
| print'\174'
} print'\175'
~ print'\176'
Groovy, 1130 bytes
My previous program, before I discovered that octal escapes exist. Much more interesting, IMO.
Each program has the form print(--'<next char>'), except:
-,[,~→print(++'<previous char>')&→print(--"'")p,r,i,n→System.out<<--'<next char>'t→'prin\u0074'(--'u')(→print'\u0028')→print'\u0029'0-9→print~-<next int>
Here is the full list of programs for each character:
print(--'!')
! print(--'"')
" print(--'#')
# print(--'$')
$ print(--'%')
% print(--'&')
& print(--"'")
' print(--'(')
( print'\u0028'
) print'\u0029'
* print(--'+')
+ print(--',')
, print(--'-')
- print(++',')
. print(--'/')
/ print(--'0')
0 print~-1
1 print~-2
2 print~-3
3 print~-4
4 print~-5
5 print~-6
6 print~-7
7 print~-8
8 print~-9
9 print~-10
: print(--';')
; print(--'<')
< print(--'=')
= print(--'>')
> print(--'?')
? print(--'@')
@ print(--'A')
A print(--'B')
B print(--'C')
C print(--'D')
D print(--'E')
E print(--'F')
F print(--'G')
G print(--'H')
H print(--'I')
I print(--'J')
J print(--'K')
K print(--'L')
L print(--'M')
M print(--'N')
N print(--'O')
O print(--'P')
P print(--'Q')
Q print(--'R')
R print(--'S')
S print(--'T')
T print(--'U')
U print(--'V')
V print(--'W')
W print(--'X')
X print(--'Y')
Y print(--'Z')
Z print(--'[')
[ print(++'Z')
\ print(--']')
] print(--'^')
^ print(--'_')
_ print(--'`')
` print(--'a')
a print(--'b')
b print(--'c')
c print(--'d')
d print(--'e')
e print(--'f')
f print(--'g')
g print(--'h')
h print(--'i')
i System.out<<--'j'
j print(--'k')
k print(--'l')
l print(--'m')
m print(--'n')
n System.out<<--'o'
o print(--'p')
p System.out<<--'q'
q print(--'r')
r System.out<<--'s'
s print(--'t')
t 'prin\u0074'(--'u')
u print(--'v')
v print(--'w')
w print(--'x')
x print(--'y')
y print(--'z')
z print(--'{')
{ print(--'|')
| print(--'}')
} print(--'~')
~ print(++'}')
><>, 443 437 bytes
TIO interpreter link. There's a lot of patterns here:
[num][num]*o;: Multiplication of two numbers, then output the result as a char withoand halt with;. ><> digits go up to 15, i.e.0123456789abcdef.- Similarly
[num][num]-n;, which takes the difference of two numbers and outputs as a number withninstead.
- Similarly
'-o[invalid char]: ><> is toroidal, so when the instruction pointer reaches the end of a line it moves back to the beginning. In this case, this causes the code to be executed twice, i.e.'-o[char]'-o[char]. The first'-o[char]'part pushes three chars to the stack,-calculates'o' - [char]thenooutputs the result as a character. ><> then errors out when it reaches[char], either due to an unrecognised command or from popping an empty stack.- Similarly
'-n[invalid char], which outputs as a number. - Similarly
'[num][op]o[invalid char], which applies[op]with[num]on[char], erroring out on char. For example,'2+oJoutputsL, which is two more thanJ. ''s code is"-oH, using"instead.-'s code is'%oB, using%instead.
- Similarly
ln;: Push length of stack, output as num then halt, giving0. Similarlylln;for1and'ln;for3.4|n+: Push 4, bounce off the|and push another 4, add, then output8as num. Bounce off the|again, and error out trying to executenagain on an empty stack.- Similarly
3|n*for9. - Similarly
[num]|o*for@Qdy.
- Similarly
'1-:00p: The most interesting one, for theocase. To avoid usingoin our code, we need to usepto place anoin the codebox, then run it. The initial'1-:00p'sets the stack up to have apon top, and1-decrements it into ano.:duplicates thiso, and00pplaces oneoat (0, 0), turning the codebox intoo1-:00p. The instruction pointer wraps again, outputting the othero. The (0, 0) char is then replaced a few more times before the program finally errors out.
'-oO
! '-oN
" '-oM
# '-oL
$ '-oK
% '-oJ
& '-oI
' "-oH
( '-oG
) '-oF
* '-oE
+ '-oD
, '-oC
- '%oB
. '-oA
/ '-o@
0 ln;
1 lln;
2 '-o=
3 'ln;
4 '-o;
5 61-n;
6 '-nh
7 '-ng
8 4|n+
9 3|n*
: '1-o;
; '6-oA
< 6a*o;
= '2+o;
> '3+o;
? 79*o;
@ 8|o*
A '-o.
B '-o-
C '-o,
D '-o+
E '-o*
F '-o)
G '-o(
H 89*o;
I '1-oJ
J '-o%
K '-o$
L '2+oJ
M 7b*o;
N '-o!
O '5+oJ
P 8a*o;
Q 9|o*
R '8+oJ
S '9+oJ
T 7c*o;
U 'b+oJ
V 'c+oJ
W 'd+oJ
X 8b*o;
Y 'f+oJ
Z 9a*o;
[ 7d*o;
\ 'c-oh
] 'b-oh
^ 'a-oh
_ '9-oh
` 8c*o;
a '7-oh
b 7e*o;
c 9b*o;
d a|o*
e '3-oh
f '2-oh
g '1-oh
h '2-oj
i 8d*o;
j '2+oh
k '3+oh
l 9c*o;
m '5+oh
n ab*o;
o '1-:00p
p 8e*o;
q '3-ot
r '2-ot
s '1-ot
t '1+os
u 9d*o;
v '2+ot
w '3+ot
x ac*o;
y b|o*
z '6+ot
{ '7+ot
| '8+ot
} '9+ot
~ 9e*o;
><>, 531 bytes
The programs take two main forms:
##*o;
"chr-1"1+o;
The first is for characters with character codes with two factors both less than 16, the other is for the other cases. Most numbers that I use the second form for have many equal length solutions, but I chose that one for readability.
Exceptions:
" b3*1+o; Would be "!"1+o; normally
0 11-n; n outputs as a number
1 22/n;
2-9 #1+n;
; ":"1+o* Ends in an error
Full list:
! b3*o;
" b3*1+o;
# 57*o;
$ 66*o;
% "$"1+o;
& "%"1+o;
' d3*o;
( a4*o;
) "("1+o;
* ")"1+o;
+ ","1-o;
, b4*o;
- 95*o;
. "-"1+o;
/ "."1+o;
0 11-n;
1 22/n;
2 11+n;
3 21+n;
4 31+n;
5 41+n;
6 51+n;
7 61+n;
8 71+n;
9 81+n;
: "9"1+o;
; ":"1+o*
< a6*o;
= "<"1+o;
> "="1+o;
? 97*o;
@ 88*o;
A d5*o;
B b6*o;
C "B"1+o;
D "C"1+o;
E "D"1+o;
F a7*o;
G "F"1+o;
H 98*o;
I "H"1+o;
J "D"1+o;
K e5*o;
L "K"1+o;
M b7*o;
N d6*o;
O "D"1+o;
P a8*o;
Q 99*o;
R "Q"1+o;
S "R"1+o;
T c7*o;
U "T"1+o;
V "U"1+o;
W "V"1+o;
X b8*o;
Y "X"1+o;
Z a9*o;
[ c7*o;
\ "["1+o;
] "\"1+o;
^ "]"1+o;
_ "^"1+o;
` c8*o;
a "`"1+o;
b e7*o;
c b9*o;
d aa*o;
e "d"1+o;
f "e"1+o;
g "g"1+o;
h d8*o;
i e7*o;
j "i"1+o;
k "j"1+o;
l c9*o;
m "l"1+o;
n ba*o;
o DNP
p e8*o;
q "p"1+o;
r "q"1+o;
s "r"1+o;
t "s"1+o;
u c9*o;
v "u"1+o;
w "v"1+o;
x ca*o;
y bb*o;
z "y"1+o;
~ e9*o;
Minkolang 0.15, 604 bytes
For most characters, "<char-1>"1+O. would be a valid program, perhaps one of the shortest. However, due to the fact that characters are stored as code points on the stack means that many of them can be produced by multiplication and addition, in five bytes or fewer. Also, note that l, $1, $2, $3, $4, $5, $6, $l are 10, 11, 12, 13, 14, 15, 16, 100 respectively.
Format: <character>: <program>
: 48*O.
!: $13*O.
": 66*2-O.
#: 57*O.
$: 66*O.
%: 66*1+O.
&: 4l*2-O.
': 3$3*O.
(: 4l*O.
): 4l*1+O.
*: ")"1+O.
+: "*"1+O.
,: $14*O.
-: 59*O.
.: "-"1+d$10pO-
/: "."1+O.
0: 68*O.
1: 77*O.
2: 5l*O.
3: 5l*1+O.
4: lZIO.
5: lZdIO.
6: 239**O.
7: 5$1*O.
8: 4$4*O.
9: 6l*3-O.
:: 6l*2-O.
;: 6l*1-O.
<: 6l*O.
=: 6l*1+O.
>: 6l*2+O.
?: 79*O.
@: 88*O.
A: 5$3*O.
B: 6$1*O.
C: 7l*3-O.
D: 7l*2-O.
E: 7l*1-O.
F: 7l*O.
G: 7l*1+O.
H: 89*O.
I: 89*1+O.
J: 89*2+O.
K: 355**O.
L: 89*4+O.
M: 7$1*O.
N: 6$3*O.
O: "N"1+d90pN.
P: 8l*O.
Q: 99*O.
R: 8l*2+O.
S: 8l*3+O.
T: 347**O.
U: 8l*5+O.
V: 8l*6+O.
W: 8l*7+O.
X: 8$1*O.
Y: 8l*9+O.
Z: 9l*O.
[: $l9-O.
\: $l8-O.
]: $l7-O.
^: $l6-O.
_: $l5-O.
`: 8$2*O.
a: $l3-O.
b: $l2-O.
c: 9$1*O.
d: $lO.
e: $l1+O.
f: $l2+O.
g: $l3+O.
h: $l4+O.
i: $l5+O.
j: $l6+O.
k: $l7+O.
l: $l8+O.
m: $l9+O.
n: l$1*O.
o: $l$1+O.
p: $l$2+O.
q: $l$3+O.
r: $l$4+O.
s: $l$5+O.
t: $l$6+O.
u: "t"1+O.
v: "u"1+O.
w: 7dl+*O.
x: 358**O.
y: $1d*O.
z: 53;3-O.
{: 53;2-O.
|: 53;1-O.
}: 53;O.
~: 53;1+O.
Special mentions:
.: "-"1+d$10pO-
(Try it.) Minkolang has the ability to modify the characters in the code box, so what this program does is that it replaces that - at the end with ., which is necessary for stopping the program. "N"1+d90pN. for O works the same way.
4: lZIO.
(Try it.) lZ pushes the uppercase and lowercase alphabets to the stack, and I pushes the length of the stack, which is 52, precisely the code point of "4". The best part is that I was initially considering the solution of 4$3*O., which multiplies 4 and 13 to get 52, but couldn't because it had a 4 in it, so I ended up finding a golfier solution anyway!
y: $1d*O.
(Try it.) d duplicates the top of stack, so what this piece of code does is that it pushes 11, duplicates it, and then multiplies. An alternate way to write this would have been $12;O., which has the same byte count.
}: 53;O.
(Try it.) ; is exponentiation, so this does 5^3 to get 125.
05AB1E, 417 bytes
! 62D>B
" 63D>B
# 64D>B
$ 65D>B
% 66D>B
& 67D>B
' 68D>B
( 69D>B
) 70D>B
* 71D>B
+ 72D>B
, 73D>B
- 74D>B
. 75D>B
/ 76D>B
0 1<
1 X
2 Y
3 Z
4 3>
5 4>
6 5>
7 6>
8 7>
9 8>
: 77D>B
; 78D>B
< 79D>B
= 80D>B
> 81D1+B
? 82D>B
@ 83D>B
A Th
B T>h
C T>>h
D T3+h
E T4+h
F T5+h
G 16D>B
H 17D>B
I 18D>B
J 19D>B
K 20D>B
L 21D>B
M 22D>B
N 23D>B
O 24D>B
P 25D>B
Q 26D>B
R 27D>B
S 28D>B
T 29D>B
U 30D>B
V 31D>B
W 33D>B
X 33D>B
Y A`\u
Z A`u
[ 84D>B
\ 85D>B
] 86D>B
^ 87D>B
_ 88D>B
` 89D>B
a A`r
b A`r\
c 38D>B
d 39D>B
e 40D>B
f 41D>B
g 42D>B
h 43D>B
i 44D>B
j 45D>B
k 46D>B
l 47D>B
m 48D>B
n 49D>B
o 50D>B
p 51D>B
q 52D>B
r 53D>B
s 54D>B
t 55D>B
u 56D>B
v 57D>B
w 58D>B
x A`\\
y A`\
z A`
{ 90D>B
| 91D>B
} 92D>B
~ 93D>B
Explanation
Most are 5 bytes long of the form: convert nr to base nr+1.
> needs an extra byte since we can't use increment for that.
a,b,x,y,z,Y,Z are extracted from A which contains the alphabet in lower case.
A,B,C,D,E,F are numbers converted to hex.
0-9 are simple increment/decrements as well as predefined variables.
JavaScript (ES6), 1083 1068 bytes
General form:
alert`\xhex`
Exceptions:
0 alert(9-9)
...
8 alert(9-1)
9 alert(8+1)
\ alert(atob`XA`)
` alert('\x60')
a \u0061lert`\x61`
e al\u0065rt`\x65`
l a\u006cert`\x6c`
r ale\u0072t`\x72`
t aler\u0074`\x74`
x alert`\u0078`
Edit: Saved 15 bytes thanks to @GOTO0.
Brachylog, 546 477 bytes
Credits to Fatalize for the code for @.
In the list below, the first character is the character to be printed (for easy reference).
@S
! @Ht
" @P:2m
# @P:3m
$ @P:4m
% @P:5m
& @P:6m
' @P:7m
( @P:8m
) @P:9m
* @P:10m
+ @P:11m
, @H:5m
- @P:13m
. @P:14m
/ @P:15m
0 1-
1 0+
2 1+
3 2+
4 3+
5 4+
6 5+
7 6+
8 7+
9 8+
: @P@4bhbbbh
; @P:27m
< @P:28m
= @P:29m
> @P:30m
? @P:31m
@ "?":"A"ybh
A @Zt@u
B @Ch@u
C @P:35m
D @P:36m
E @P:37m
F @P:38m
G @P:39m
H @P:40m
I @P:41m
J @P:42m
K @P:43m
L @P:44m
M @P:45m
N @P:46m
O @P:47m
P @A:15m@u
Q @P:49m
R @P:50m
S @P:51m
T @P:52m
U @Vt@u
V @P:54m
W @Qt@u
X @P:56m
Y @Wt@u
Z @At@u
[ @P:59m
\ @P:60m
] @P:61m
^ @P:62m
_ @P:63m
` @P:64m
a @Vh
b @Ch
c @Dbh
d @A:3m
e @Vbh
f @A:5m
g @A:6m
h @A:7m
i @A:8m
j @A:9m
k @C:7m
l @C:8m
m @D@2ht
n @A:13m
o @H:4m
p @A:15m
q @Z:9m
r @Z:8m
s @Z:7m
t @Z:6m
u @Vt
v @Z:4m
w @Qt
x @Z:2m
y @Wt
z @At
{ @P:91m
| @P:92m
} @Prbh
~ @Pt
They are all predicates, so Z needs to be the argument to receive the output: Try it online!
Explanation
@P is this string:
!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~
which contains every printable ASCII.
WolframAlpha, 368 bytes
General format:
u+<character code in hexadecimal>
Exceptions:
Character Code
+ plus
0 1-1
1 0!
2 1+1
3 1+2
4 2+2
5 2+3
6 3!
7 3+4
8 4+4
9 4+5
u U+75
Here is the full list:
u+20
u+21
u+22
u+23
u+24
u+25
u+26
u+27
u+28
u+29
u+2A
plus
u+2C
u+2D
u+2E
u+2F
1-1
0!
1+1
1+2
2+2
2+3
3!
3+4
4+4
4+5
u+3A
u+3B
u+3C
u+3D
u+3E
u+3F
u+40
u+41
u+42
u+43
u+44
u+45
u+46
u+47
u+48
u+49
u+4A
u+4B
u+4C
u+4D
u+4E
u+4F
u+50
u+51
u+52
u+53
u+54
u+55
u+56
u+57
u+58
u+59
u+5A
u+5B
u+5C
u+5D
u+5E
u+5F
u+60
u+61
u+62
u+63
u+64
u+65
u+66
u+67
u+68
u+69
u+6A
u+6B
u+6C
u+6D
u+6E
u+6F
u+70
u+71
u+72
u+73
u+74
U+75
u+76
u+77
u+78
u+79
u+7A
u+7B
u+7C
u+7D
u+7E
BBC Basic, 422 413 bytes
Download interpreter free at http://www.bbcbasic.co.uk/bbcwin/bbcwin.html
9 bytes saved thanks to Leaky Nun.
General form
V.<character code>
32..99 excluding 12 special cases: 56x4= 224 bytes
100..126 : 27x5= 135 bytes
12 special cases : 54 bytes
Most numbers follow the general form, but I included them all here to show where the problem is.
First character is the character to be printed.
. VDU46 :REM Full form of the command used in general form: send character 46 to VDU)
V P.CHR$86 :REM short for PRINT CHR$(86)
0 V.48
1 V.49
2 V.50
3 V.51
4 V.52
5 P.1+4
6 V.54
7 V.55
8 V.56
9 V.57
MATL, 305, 302, 300 297 bytes
Every single program looks like this:
33c
34c
35c
....
Except for
Digits. Here are the programs for 0-9:
O l H I K 4Q 5Q 6Q 7Q 8Q'c'. This program is
'C'kspace. This is
0cSince today I learned, that MATL treats character 0 as space. Thanks @LuisMendo!
You can use matl.tio to verify any of them.
For reference, here is all of them:
0c
33c
34c
35c
36c
37c
38c
39c
40c
41c
42c
43c
44c
45c
46c
47c
O
l
H
I
K
4Q
5Q
6Q
7Q
8Q
58c
59c
60c
61c
62c
63c
64c
65c
66c
67c
68c
69c
70c
71c
72c
73c
74c
75c
76c
77c
78c
79c
80c
81c
82c
83c
84c
85c
86c
87c
88c
89c
90c
91c
92c
93c
94c
95c
96c
97c
98c
'C'k
100c
101c
102c
103c
104c
105c
106c
107c
108c
109c
110c
111c
112c
113c
114c
115c
116c
117c
118c
119c
120c
121c
122c
123c
124c
125c
126c
Ruby, 869 bytes
For the 63 characters @ through ~, we have a 10-byte solution:
$><<"\xxx" (3 digit octal code)
$><<92.chr (special case for \)
For most (21) characters from space through ?, we have a 9-byte solution:
puts"\xx" (2 digit octal code)
There are eleven special cases left:
$><<34.chr (10 bytes for ")
p$. (3 bytes for 0)
p~-2 \
p~-3 \ (4 bytes for 1-8)
... /
p~-9 /
p 1+8 (5 bytes for 9)
In total, the score is 10×63 + 9×21 + 10 + 3 + 8×4 + 5 = 869.
CJam, 269 bytes
Each of the programs are in the form '<char - 1>) except for:
- Space =>
S, 1 byte '=>39c, 3 bytes)=>'*(, 3 bytes0=>T, 1 byte1=>X, 1 byte2=>Y, 1 byte3=>Z, 1 byte4-9=><num-1>), 2 bytes
Score is: 3 * 82 + 1 + 3 + 3 + 4 * 1 + 6 * 2 = 269
Pyke, 364 362 355 bytes
2*1 + 3*2 + 14*3 + 2*4 + 5 + 73*4
All in the form w<chr(charcode+32)>.C (4 bytes) except for:
->d1 byte0->Z1 byte1->~W2 bytesa->Gh2 bytesz->Ge2 bytes- First 10 lowercase alphabet letters (except
a) in formG<number>@(3 bytes) k->GT@3 bytes>->~Bh3 bytes]->~Be3 bytesZ->~le3 bytes9->~ue3 bytesw->G22@4 bytes.->~B4@4 bytesC->~K38@5 bytes