60
\$\begingroup\$

In a programming language of your choice, write 95 programs, each of which outputs a different one of the 95 printable ASCII characters without that character occurring anywhere in the program.

For example, if your language was Python, your program that outputs the character P might be

print(chr(80))

because P has ASCII code 80. This program is valid because P never appears in the source code. However, for the program that outputs lowercase p, something like

print(chr(112))

would be invalid because, while it does print p, p is present in the code. A valid program could be

exec(chr(112)+'rint(chr(112))')

which prints p but does not contain p.

Your goal is to make each of your 95 programs as short as possible. Your score is the sum of the character lengths of all your programs.

If for any reason you are unable to write valid programs for some characters, you may mark those characters as "Did Not Program" or DNP, and omit programs for them entirely. This way syntactically strict languages will be able to compete.

The winning answer is the answer that has the lowest score of the set of answers that have the fewest DNP's.

Rules

  • The source code of all of your programs may only contain printable ASCII plus tabs and newlines, all of which are counted as one character. (Because in a different encoding it would be easy to omit characters that don't exist!)

    • Note: This rule seems necessary but there are many languages with different encodings and I'm sure it'd be cool to see the answers for them. Therefore you can break this rule, you can use whatever characters you want, but then your answer becomes non-competitive, it cannot win.
  • The programs must be actual, full programs, according to your language's standard conventions. Functions and REPL snippets are not allowed.

  • Each program's output should go to stdout or your language's accepted alternative.

  • Programs should not prompt for or require input. (If prompting for input is inherent to your language, that's ok.)

  • Programs should be deterministic, finite in run time, and independent. e.g. it shouldn't matter if one is run in a folder separate from the other programs.

  • A program's output should be the precise printable ASCII character it corresponds to, optionally followed by a single trailing newline, nothing more, nothing less.

Be sure to include information on all 95 (ideally) programs in your answer, as well as your score and any DNP's. You don't have to list all programs that follow a simple pattern like "print(chr(80)), print(chr(81)), print(chr(82))..." but make sure you're sure they all would work and that your score is added correctly.

For reference, here are the 95 printable ASCII your programs must output:

 !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~
\$\endgroup\$
8
  • \$\begingroup\$ If in my encoding 0x30 codes for, say, 日 rather than 0, then can I assume that the printable ASCII are the regular 95, minus 0, add 日? \$\endgroup\$
    – Leaky Nun
    Commented Aug 21, 2016 at 13:08
  • 4
    \$\begingroup\$ What? You need to use printable ASCII. That's just a rule. \$\endgroup\$ Commented Aug 21, 2016 at 13:10
  • 3
    \$\begingroup\$ @Tim No. Doesn't follow the independence rule. \$\endgroup\$ Commented Aug 22, 2016 at 2:21
  • 1
    \$\begingroup\$ Am I required to use ASCII-1967, or is ASCII-1963 okay? \$\endgroup\$
    – Mark
    Commented Aug 22, 2016 at 23:16
  • 1
    \$\begingroup\$ @Mark Use the modern '67 version. \$\endgroup\$ Commented Aug 27, 2016 at 3:28

60 Answers 60

1
2
2
\$\begingroup\$

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*,@
\$\endgroup\$
1
\$\begingroup\$

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

Try it online!

Golfing suggestions are welcome.

\$\endgroup\$
2
  • \$\begingroup\$ : in 5: 9P2*c \$\endgroup\$
    – user45941
    Commented Aug 22, 2016 at 6:51
  • \$\begingroup\$ @Mego Thanks, added. \$\endgroup\$
    – Leaky Nun
    Commented Aug 22, 2016 at 6:52
1
\$\begingroup\$

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+O
    

    That'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 of CKQT, because otherwise the corresponding DLRU in the code would create another, unwanted atom. These are still 5 bytes.
  • For O, we can't use O for 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/;
    

    R and L both create an atom (initially with mass 1). The right-going one's mass is incremented twice to 3 (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 mass 39 (') going south and one with mass 79 (O) going north. Since the grid wraps around, they both hit the ;. The O atom is deflected onto the ; where it is destroyed. The ' is deflected onto the O which (as usual) prints the character and destroys the atom.

\$\endgroup\$
0
1
\$\begingroup\$

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 309P it is use the same A-F behavior with 4DP (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
\$\endgroup\$
6
  • 3
    \$\begingroup\$ You can shave some bytes off if you represent some numbers in hex (dc will automagically interpret them as such if they contain a-f)- 106-111, 122-127 \$\endgroup\$
    – Delioth
    Commented Aug 23, 2016 at 17:44
  • \$\begingroup\$ @Delioth I thought that too and gave it a try, but at least on the implementation available to me ATM (cygwin), if input radix is set to 10 as it is by default, entering A-F (a-f won't ever work as a, c, d, and f are commands) always return '9' unless it's just that digit on its own, in which case it returns its value. Ap yields 10; 6Ap yields 69; 6AP yields E; Fp yields 15 6Fp yields 69; 6FP yields E \$\endgroup\$
    – brhfl
    Commented Aug 23, 2016 at 18:18
  • \$\begingroup\$ @Delioth Alright, now that I'm on a better environment, I'm getting results more in line with what I expected - on both my Mac and Ubuntu, 6F is 75… That is, it's not hex per se, but any given decimal place can represent 0-15 with a carry. I'll suss out what I can exploit in this way and update accordingly… Actually, that simplifies everything >99. Thanks! \$\endgroup\$
    – brhfl
    Commented Aug 24, 2016 at 1:14
  • 1
    \$\begingroup\$ 4DP works for 5. Also, I thought it appropriate to link this. \$\endgroup\$
    – juh
    Commented Aug 24, 2016 at 1:42
  • \$\begingroup\$ And here, dear friend, is a stabler port of dc for Windows. (It's bundled with bc.) :) \$\endgroup\$
    – juh
    Commented Aug 24, 2016 at 1:57
1
\$\begingroup\$

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 1 I 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 using e (the only non pure sed program)
\$\endgroup\$
1
\$\begingroup\$

Forth, 694 bytes

Try it online

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+ .
\$\endgroup\$
1
\$\begingroup\$

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)
\$\endgroup\$
1
\$\begingroup\$

Add++, 505 bytes

Almost all of the programs have the format

+<char code>
H

Try it online!

With the exception of 3, the programs that generate "5", "+" and "H", which are, respectively

+4
+1
O

Try it online!

x:43
H

Try it online!

+72
h

Try it online!

How they work:

  • Most work by setting that active variable to their charcode, and H converts 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 using h, which outputs the same result as H, without a trailing newline

The bytecount was calculated using this program.

\$\endgroup\$
1
\$\begingroup\$

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
\$\endgroup\$
1
\$\begingroup\$

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.

\$\endgroup\$
1
\$\begingroup\$

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

\$\endgroup\$
12
  • \$\begingroup\$ Why not just have \<char+1>; for everything \$\endgroup\$
    – lyxal
    Commented Aug 18, 2019 at 22:12
  • \$\begingroup\$ You don't need to escape everything. There are also non-commands in Reg. \$\endgroup\$
    – user85052
    Commented Aug 19, 2019 at 0:54
  • \$\begingroup\$ (In order to shorten byte count) \$\endgroup\$
    – user85052
    Commented Aug 19, 2019 at 1:54
  • \$\begingroup\$ I realised that my suggestion was longer than your idea, so I went to delete it but my phone was special and posted the comment. \$\endgroup\$
    – lyxal
    Commented Aug 19, 2019 at 4:49
  • \$\begingroup\$ This seems to be the shortest answer right now! \$\endgroup\$
    – lyxal
    Commented Aug 19, 2019 at 10:44
1
\$\begingroup\$

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 of O A53, we do O A+9 44.
  • The O is a DNP, as it's the only way to do output. (Technically DUMP can too, but it doesnt output only its argument.)
  • The A one 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) use ASCII. FALSE almost does it, except it converts to the lower-case false, not FALSE. So, A is 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 # ~
\$\endgroup\$
1
  • \$\begingroup\$ If it's Knight 1.2 we can use EVAL to print O, though we can't use that to print A. \$\endgroup\$
    – Aiden Chow
    Commented Oct 1, 2022 at 8:36
1
\$\begingroup\$

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 Test it
Quotation Q Test it
Hash 35d Test it
Dollar ;Gd Test it
Percentage 37d Test it
Ampersand Test it
Apostrophe Hd7 Test it
Left Bracket d40 Test it
Right Bracket K¤Ì Test it
Asterisk Test it
Plus Test it
Comma ;J Test it
Minus 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 Test it
Seven Test it
Eight Iq Test it
Nine Test it
Colon d58 Test it
Semi-Colon 59d Test it
Less Than Test it
Equals Test it
Greater Than 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 ... ...
\$\endgroup\$
4
  • 1
    \$\begingroup\$ Just in case, you're aware of the rule "The source code of all of your programs may only contain printable ASCII plus tabs and newlines, all of which are counted as one character. (Because in a different encoding it would be easy to omit characters that don't exist!)"? I assume there should be ASCII-only alternatives for some of the programs you're currently using unicode characters for? \$\endgroup\$ Commented Sep 23, 2022 at 11:38
  • 1
    \$\begingroup\$ See the next point below that, @KevinCruijssen: "This rule seems necessary but there are many languages with different encodings and I'm sure it'd be cool to see the answers for them. Therefore you can break this rule, you can use whatever characters you want, but then your answer becomes non-competitive, it cannot win." This would be trivial in Japt with the ASCII only restriction; I wanted the challenge so opted for a non-competitive solution. \$\endgroup\$
    – Shaggy
    Commented Sep 23, 2022 at 11:47
  • \$\begingroup\$ Ah ok, didn't knew you were going for a non-competitive answer on purpose. :) Cary on. (Maybe add both an additional column so you'll have both a competitive and non-competitive column?) \$\endgroup\$ Commented Sep 23, 2022 at 11:51
  • \$\begingroup\$ Yep, I plan to take 2 more passes over this when I'm finished; one to see if I can knock a byte off any of the 2-3 byte solutions and another to add a set of ASCII only solutions. \$\endgroup\$
    – Shaggy
    Commented Sep 23, 2022 at 11:54
1
\$\begingroup\$

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:

  • s is a builtin for space
  • i is a builtin for 0
  • o is a builtin for 1
  • AZ@2 indexes into the builtin uppercase alphabet for C, avoiding the Chr operator
  • Ch is shorter for d than z@3
  • z@t is shorter for k than z@10
  • C122 avoids using z for z

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
\$\endgroup\$
2
  • \$\begingroup\$ Your code to output a 'z' uses the character 'z': "z@v" \$\endgroup\$ Commented Aug 22, 2016 at 9:46
  • \$\begingroup\$ @FlorianBach Fixed \$\endgroup\$
    – DLosc
    Commented Aug 22, 2016 at 17:36
1
\$\begingroup\$

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:]
\$\endgroup\$
0
\$\begingroup\$

Reng, 564 560 bytes, non-competing

Try them here!

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
\$\endgroup\$
0
\$\begingroup\$

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

Try it online!

\$\endgroup\$
0
\$\begingroup\$

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...

\$\endgroup\$
2
  • \$\begingroup\$ @DJMcMayhem deadfish can only output 10 characters, hence only 10 programs and 85 DNP \$\endgroup\$ Commented Sep 2, 2016 at 0:24
  • \$\begingroup\$ Oh, Okay I misunderstood that. \$\endgroup\$
    – DJMcMayhem
    Commented Sep 2, 2016 at 0:25
0
\$\begingroup\$

Sesos, 285 bytes (non-competing)

Every program is compiled by using this syntax:

add <decimal-ascii-code>
put

Try it online!

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.

\$\endgroup\$
0
\$\begingroup\$

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 course q, 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"
\$\endgroup\$
0
\$\begingroup\$

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.

\$\endgroup\$
0
\$\begingroup\$

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'~'
\$\endgroup\$
2
  • 1
    \$\begingroup\$ Isn't using chr so much shorter for basically every one? Also, why is this marked non-competing? \$\endgroup\$
    – Jo King
    Commented Aug 19, 2019 at 11:17
  • \$\begingroup\$ I thought perhaps it wasn't eligible to compete or the byte/character count would be too high. Will change it now. \$\endgroup\$ Commented Aug 19, 2019 at 11:36
0
\$\begingroup\$

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
...

Attempt This Online!

\$\endgroup\$
0
\$\begingroup\$

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)
'{)
'|)
'})

Try it online.

Explanation:

  • !"#%&: Push constant integers with this codepoint (U=33 through Z=38, except for X=36), and convert it from an integer to a character with $
  • ': Same, but with Z incremented to 39 with ) before the $
  • 0: + in an empty program without input, it'll implicitly use 0 for mathematical builtins, so it'll implicitly do 0+0, which results in 0
  • 1: ) increments once, so just like the + it'll implicitly use a 0, which gets incremented to 1
  • 23456789: 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):

Try it online.

\$\endgroup\$
2
  • 1
    \$\begingroup\$ You've used $ to output "$". \$\endgroup\$
    – Shaggy
    Commented Sep 23, 2022 at 20:37
  • \$\begingroup\$ @Shaggy Woops, you're completely right! Fixed. Thanks for noticing. \$\endgroup\$ Commented Sep 24, 2022 at 11:40
0
\$\begingroup\$

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);}
\$\endgroup\$
3
  • \$\begingroup\$ I only know very basic C, can you explain why this works? main _){putchar _ 40);}? \$\endgroup\$
    – Jonah
    Commented Sep 25, 2022 at 13:44
  • \$\begingroup\$ @Jonah, the flag: -D_=( defines _ as (. \$\endgroup\$
    – jdt
    Commented Sep 25, 2022 at 13:57
  • \$\begingroup\$ Doesn’t this defeat the purpose of the rule of avoiding the character to be printed? As far as I understand ‑D is expanded by a preprocessor so your source code effectively contain forbidden characters nevertheless, right? \$\endgroup\$ Commented Mar 12 at 20:00
0
\$\begingroup\$

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

\$\endgroup\$
1
  • 1
    \$\begingroup\$ I don't think it's valid with the inverted commas in the output. \$\endgroup\$
    – jdt
    Commented Sep 26, 2022 at 13:33
0
\$\begingroup\$

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)
\$\endgroup\$
2
  • \$\begingroup\$ @JoKing print, put, write, cout all contain t \$\endgroup\$
    – l4m2
    Commented Nov 11, 2018 at 11:14
  • \$\begingroup\$ @JoKing That's what +1char meant \$\endgroup\$
    – l4m2
    Commented Nov 11, 2018 at 11:21
0
\$\begingroup\$

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.

Test code

 ->  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"
\$\endgroup\$
1
  • \$\begingroup\$ Most of these can be shortened by using say instead of print. Also, there are shorter was of getting a space, 0 and 1: Try it online! \$\endgroup\$
    – Xcali
    Commented Mar 12 at 20:22
0
\$\begingroup\$

Vyxal, score 241

ð
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
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
«ƛ
«¬
«∧
«⟑
«∨
«⟇
«÷
«×
«

«»
«°
«•
«ß
Ǡ
«€
«½
«∆
«ø
«↔
«¢
«⌐
«æ
«ʀ
«ʁ
«ɾ
«ɽ
⁺⌐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.

\$\endgroup\$
0
\$\begingroup\$

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.

\$\endgroup\$
0
1
2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.