Print every printable ASCII character without using it

56

6

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{|}~

Calvin's Hobbies

Posted 2016-08-21T13:01:16.383

Reputation: 84 000

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 日? – Leaky Nun – 2016-08-21T13:08:10.727

4What? You need to use printable ASCII. That's just a rule. – Calvin's Hobbies – 2016-08-21T13:10:47.207

I believe there are encodings which do not have the exact representation of 0x30 as 0 – Leaky Nun – 2016-08-21T13:17:36.943

@LeakyNun EBCDIC – TuxCrafting – 2016-08-21T13:59:09.890

Could I specify a condition such as "must be run in a directory which only contains a file named " " (space)"? – Tim – 2016-08-22T02:18:00.763

2@Tim No. Doesn't follow the independence rule. – Calvin's Hobbies – 2016-08-22T02:21:29.677

Am I required to use ASCII-1967, or is ASCII-1963 okay? – Mark – 2016-08-22T23:16:46.337

@Mark Use the modern '67 version. – Calvin's Hobbies – 2016-08-27T03:28:55.003

Answers

25

Python 2, 1075 1065 1043 1040 1039 bytes

Each program has the form print'\<octal char code>', except:

  • 'print"\47"
  • 0 through 8print~-<N+1>
  • 9print-~8
  • \print'%c'%92
  • iexec'pr\151nt"\151"'
  • nexec'pri\156t"\156"'
  • pexec'\160rint"\160"'
  • rexec'p\162int"\162"'
  • texec'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!

Copper

Posted 2016-08-21T13:01:16.383

Reputation: 3 684

print~-<N+1> doesn't work for 1. You said it works for 0 to 8. – haykam – 2016-08-21T20:36:06.157

7@Peanut It does. The code in <angle brackets> isn't literal code. Substitute <N+1> with the literal value of N+1; in this case, the program for 1 would be print~-2. See the full list of programs. – Copper – 2016-08-21T20:48:14.067

21

CJam, 269 bytes

Each of the programs are in the form '<char - 1>) except for:

  • Space => S, 1 byte
  • ' => 39c, 3 bytes
  • ) => '*(, 3 bytes
  • 0 => T, 1 byte
  • 1 => X, 1 byte
  • 2 => Y, 1 byte
  • 3 => Z, 1 byte
  • 4-9 => <num-1>), 2 bytes

Score is: 3 * 82 + 1 + 3 + 3 + 4 * 1 + 6 * 2 = 269

Loovjo

Posted 2016-08-21T13:01:16.383

Reputation: 7 357

39c for '? Also, you're forgetting that single digits can just be that number – Sp3000 – 2016-08-21T13:38:23.207

1@Sp3000 they can't because that would include the char you're producing in the input – Blue – 2016-08-21T13:39:11.627

But then use 1) for 2 etc to save one byte there – Luis Mendo – 2016-08-21T13:39:50.933

Sorry, 1) was what I meant yeah – Sp3000 – 2016-08-21T13:40:14.587

Also, there's TXYZ – Sp3000 – 2016-08-21T13:43:07.520

12

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:

  1. Do some xor to get a pointer to the end.
  2. sub from the last 2 words because the opcode for int is not in ASCII.
  3. Get 2 into AH and the character into DL. Both are xored because the character itself can't appear in the program and 2 is not a printable ASCII character.
  4. Print the character with int 21h
  5. 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

Michael Ehrenreich

Posted 2016-08-21T13:01:16.383

Reputation: 799

11

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

betseg

Posted 2016-08-21T13:01:16.383

Reputation: 8 493

1I don't understand why this was downvoted... – Beta Decay – 2016-08-21T14:03:34.177

3@βετѧΛєҫαγ Probably since it was mostly copied. – Calvin's Hobbies – 2016-08-21T14:27:10.960

@HelkaHomba Ahh probably – Beta Decay – 2016-08-21T14:30:50.930

8@HelkaHomba I mean, BF constants are basically the shortest from what I know. Trying to do it yourself on already established constants is pointless. – Insane – 2016-08-22T06:25:51.857

@Insane even then it would make sense to post your answer as CW if it's 99% copy paste – John Dvorak – 2016-08-23T15:01:29.493

Actually, I retract my previous comment - this is standard loophole abuse.

– Mego – 2016-08-26T07:29:18.063

1@Mego There is nothing to be improved over the values from the BF constants list. AFAIK they're proven to be optimal. I don't see any problem with this answer, and it's great to have it for the sake of completeness of this challenge. It's not RHN's fault that someone has already brute-forced the optimal snippets for all relevant numbers elsewhere on the internet. – Martin Ender – 2016-08-27T22:56:16.910

3--[>-<---]>[<->--]<[->-<]>. works for output +. – Dennis – 2016-08-27T23:31:25.467

3@Dennis A bit of bashing later: -----[[----<]>>-]<. – Sp3000 – 2016-08-28T06:03:34.137

2Also +[+[+>]<<++++]>. – Sp3000 – 2016-08-28T06:08:36.747

9

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'k
    
  • space. This is

    0c
    

    Since 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

James

Posted 2016-08-21T13:01:16.383

Reputation: 54 537

@LuisMendo I'm still counting 297 – James – 2016-08-21T15:13:28.550

@LuisMendo I count 297 also. – Leaky Nun – 2016-08-21T15:15:33.563

Sorry, my mistake – Luis Mendo – 2016-08-21T16:35:03.213

9

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");}}
  • 0interface A{static void main(String[]a){System.out.print(1-1);}}
  • 1interface A{static void main(String[]a){System.out.print(3-2);}}
  • 2interface A{static void main(String[]a){System.out.print(3-1);}}
  • 3interface A{static void main(String[]a){System.out.print(4-1);}}
  • 4interface A{static void main(String[]a){System.out.print(5-1);}}
  • 5interface A{static void main(String[]a){System.out.print(6-1);}}
  • 6interface A{static void main(String[]a){System.out.print(7-1);}}
  • 7interface A{static void main(String[]a){System.out.print(8-1);}}
  • 8interface A{static void main(String[]a){System.out.print(9-1);}}
  • 9interface A{static void main(String[]a){System.out.print(8+1);}}
  • ;interface A{static void main(String[]a){System.out.print("\73")\u003B}}
  • Ainterface B{static void main(String[]a){System.out.print("\101");}}
  • Sinterface 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");}}
  • ainterf\u0061ce A{st\u0061tic void m\u0061in(String[]b){System.out.print("\141");}}
  • cinterfa\u0063e A{stati\u0063 void main(String[]a){System.out.print("\143");}}
  • dinterface A{static voi\u0064 main(String[]a){System.out.print("\144");}}
  • eclass A{public static void main(String[]a){Syst\u0065m.out.print("\145");}}
  • fclass A{public static void main(String[]a){System.out.print("\146");}}
  • ginterface A{static void main(Strin\u0067[]a){System.out.print("\147");}}// \u0067
  • i\u0069nterface A{stat\u0069c vo\u0069d ma\u0069n(Str\u0069ng[]a){System.out.pr\u0069nt("\151");}}
  • minterface A{static void \u006Dain(String[]a){Syste\u006D.out.print("\155");}}
  • nclass A{public static void mai\u006E(Stri\u006Eg[]a){System.out.pri\u006Et("\156");}}
  • ointerface A{static v\u006Fid main(String[]a){System.\u006Fut.print("\157");}}
  • pinterface A{static void main(String[]a){System.out.\u0070rint("\160");}}
  • rclass A{public static void main(St\u0072ing[]a){System.out.p\u0072int("\162");}}
  • sinterface A{\u0073tatic void main(String[]a){Sy\u0073tem.out.print("\163");}}
  • tclass A{public s\u0074a\u0074ic void main(S\u0074ring[]a){Sys\u0074em.ou\u0074.prin\u0074("\164");}}
  • uinterface A{static void main(String[]a){System.console().printf("%c",117);}}
  • vinterface A{static \u0076oid main(String[]a){System.out.print("\166");}}
  • yinterface 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!

Copper

Posted 2016-08-21T13:01:16.383

Reputation: 3 684

2I love the random class B for printing A – Tas – 2016-08-23T05:43:52.463

You beat me to it. Yesterday at the end of the day I was writing an answer for Java using unicode escapes as well.. Ah well, +1, well-written answer and only 1 DNP isn't as bad as I thought beforehand for Java. ;) – Kevin Cruijssen – 2016-08-23T06:51:00.303

2Btw, there is a possibility to remove the DNP for u if you use Java 8+ (interface instead of class so you can remove the public) and if your OS has a Console built in, so you don't have to use System.out.print: interface A{static void main(String[]a){System.console().printf("%1",(char)117);}} Eclipse, IntelliJ and online compilers don't have this Console though, resulting in a NullPointerException. – Kevin Cruijssen – 2016-08-23T07:13:02.083

@KevinCruijssen Thanks! I'm working on reworking it now. – Copper – 2016-08-23T13:30:18.870

n: Forgot to escape print – WeaponsGrade – 2016-08-23T21:31:15.077

7

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

Adám

Posted 2016-08-21T13:01:16.383

Reputation: 37 779

1This format is less helpful than the other answers' format, in my opinion – Leaky Nun – 2016-08-21T13:56:50.373

@LeakyNun Do you mean to group them by method? There are quite a few exceptions. – Adám – 2016-08-21T13:58:15.673

2These are not all printable ASCII so technically invalid. But I'm going to add a note that non-printable ASCII is allowed for non-competitive submissions. – Calvin's Hobbies – 2016-08-21T13:59:54.437

@HelkaHomba Oops, I didn't notice that requirement. – Adám – 2016-08-21T14:09:31.273

is my new favorite smiley – Lucas Trzesniewski – 2016-08-21T20:10:09.520

7

><>, 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 with o and 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 with n instead.
  • '-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] then o outputs 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+oJ outputs L, which is two more than J.
    • ''s code is "-oH, using " instead.
    • -'s code is '%oB, using % instead.
  • ln;: Push length of stack, output as num then halt, giving 0. Similarly lln; for 1 and 'ln; for 3.

  • 4|n+: Push 4, bounce off the | and push another 4, add, then output 8 as num. Bounce off the | again, and error out trying to execute n again on an empty stack.
    • Similarly 3|n* for 9.
    • Similarly [num]|o* for @Qdy.
  • '1-:00p: The most interesting one, for the o case. To avoid using o in our code, we need to use p to place an o in the codebox, then run it. The initial '1-:00p' sets the stack up to have a p on top, and 1- decrements it into an o. : duplicates this o, and 00p places one o at (0, 0), turning the codebox into o1-:00p. The instruction pointer wraps again, outputting the other o. 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;

Sp3000

Posted 2016-08-21T13:01:16.383

Reputation: 58 729

6

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.

Lynn

Posted 2016-08-21T13:01:16.383

Reputation: 55 648

For the octal escapes you can use ?\xxx instead of "\xxx" for 1 byte each. – Jordan – 2016-08-21T15:15:45.930

Why p 1+8 and not p-~8 ? – Cyoce – 2016-08-21T18:03:45.953

@Cyoce Ruby interprets that as binary -, or something. :( – Lynn – 2016-08-21T18:19:15.433

@Jordan Noted, but I’m lazy… feel free to make the edit/recount n_n – Lynn – 2016-08-21T18:19:44.720

@Lynn right. Didn't think of that. p -~8 still looks golfier though – Cyoce – 2016-08-21T18:44:28.107

2You can do most of these shorter with putc 65 => A – histocrat – 2016-08-28T02:59:01.863

5

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

Anastasiya-Romanova 秀

Posted 2016-08-21T13:01:16.383

Reputation: 1 673

5

PHP (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

Clamburger

Posted 2016-08-21T13:01:16.383

Reputation: 151

@jimmy23013 Whoops, I misread the documentation. – Mego – 2016-08-23T09:54:51.617

You can use & | ^ between two letters to generate all printable ascii characters except <?=|;. – jimmy23013 – 2016-08-23T10:01:07.157

@jimmy23013 That's bonkers. Just when I thought I'd learnt all the quirks of PHP! – Clamburger – 2016-08-23T14:50:30.437

1many of the standard form solutions could be optimized to save a byte with binary NOT ~ instead of XOR, AND or OR. PHP can use more printable characters as constants, than just letters. – Fabian Schmengler – 2016-08-23T21:35:21.107

Actually, the -r flag is free. <?php echo Z^g; doesn't need the <?php there. And your 13-byte long solutions are actually 9 bytes long. – Ismael Miguel – 2016-08-23T22:19:55.740

1@fschmengler Unfortunately, as far as I can see, that would require the use of extended ASCII (or increasingly exotic unicode characters) which I believe is not valid for this challenge. – Clamburger – 2016-08-24T00:21:22.480

It would be perfectly valid. Just use Windows-1252 encoding. echo~Ã; yields < for example. – aross – 2016-08-24T12:43:02.547

alternatives for |: <?=g^o^t; or <?=Z^A^g; – Titus – 2017-08-16T07:03:14.987

@aross: This challenge has the printable-ascii tag.

– Titus – 2017-08-16T07:04:18.847

@Titus, old challenge, but it says in the rules that other-than-ASCII answers are encouraged, but non-competing. – aross – 2017-08-16T07:54:14.683

4

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.

Leaky Nun

Posted 2016-08-21T13:01:16.383

Reputation: 45 011

You can obtain "@" this way – Fatalize – 2016-08-21T17:22:01.563

@Fatalize Thanks, updated. – Leaky Nun – 2016-08-21T17:24:18.310

4

><>, 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;

DanTheMan

Posted 2016-08-21T13:01:16.383

Reputation: 3 140

Your ; uses ;. Also, I'm fairly sure most of these can be golfed by erroring out, and o is definitely possible. – Sp3000 – 2016-08-21T17:52:21.997

@Sp3000 Unless there is an interpreter that accepts both o and O, I don't see how o is possible. And how would ending in an error be shorter? – DanTheMan – 2016-08-21T18:05:08.317

o can be done by making using of p. I might post separately for erroring out though, because there'll probably a lot of different patterns involved. – Sp3000 – 2016-08-21T18:08:59.010

@Sp3000 I fixed the ; program though. Thanks for pointing that out! – DanTheMan – 2016-08-21T18:09:37.163

4

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 either S2;: or S3;%. 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 U which would require U3;@. There are several ways to fix this, including switching to lower-case, i.e. n9;@, or using increment or decrement, i.e. T);@ or V(;@. In any case it's still four bytes.
  • Memory edges are initialised to 0, and ! prints an integer value, so we can get 0 and 1 with !@ 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.

Martin Ender

Posted 2016-08-21T13:01:16.383

Reputation: 184 808

4

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]

Rolf

Posted 2016-08-21T13:01:16.383

Reputation: 51

2The space is a printable ASCII character ("printable ASCII" refers to the range 0x20 to 0x7E, inclusive), so you'll have to include that as 1 DNP unless you can find a way to print it without using any spaces. Apart from that, please include the score of the program. – Martin Ender – 2016-08-22T12:01:42.123

4

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 of xs 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:

    
    1
    
    
  • 3: same thing but we turn the input into two characters:

    
    11
    
    
  • 4: you get the idea...

    
    111
    
    
  • 5 - 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

Martin Ender

Posted 2016-08-21T13:01:16.383

Reputation: 184 808

With the new version of Retina it's possible to print all letters (even T) with four bytes using $L and $u... I still couldn't find a way to print the backtick without using it, do you think it's possible? – Leo – 2018-03-01T22:38:57.693

@Leo No, I don't think so. I've been meaning to add another binary operator to substitution syntax which would be range expansion, which would solve the problem. I need to figure out how exactly I want to implement it though. Another option would be some substitution syntax feature to work with code points. – Martin Ender – 2018-03-01T23:15:36.290

3

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:

  • -> d 1 byte
  • 0 -> Z 1 byte
  • 1 -> ~W 2 bytes
  • a -> Gh 2 bytes
  • z -> Ge 2 bytes
  • First 10 lowercase alphabet letters (except a) in form G<number>@ (3 bytes)
  • k -> GT@ 3 bytes
  • > -> ~Bh 3 bytes
  • ] -> ~Be 3 bytes
  • Z -> ~le 3 bytes
  • 9 -> ~ue 3 bytes
  • w -> G22@ 4 bytes
  • . -> ~B4@ 4 bytes
  • C -> ~K38@ 5 bytes

Online Pyke interpreter

Blue

Posted 2016-08-21T13:01:16.383

Reputation: 26 661

3

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.

Neil

Posted 2016-08-21T13:01:16.383

Reputation: 95 035

"x" needs special handling, too. Also, use alert(atob\XA`)` for "" to save a few bytes. – GOTO 0 – 2016-08-21T17:11:12.980

@GOTO0 Ugh, I can't believe I forgot x. – Neil – 2016-08-21T17:56:26.653

1Javascript allows \u escapes in source code? Cool – Cyoce – 2016-08-21T18:54:11.043

@Cyoce: In identifiers, yes, in general, no. – Bergi – 2016-08-21T23:02:28.110

@Bergi Unicode escapes are processed first, so you can write your entire source in terms of unicode escapes if you like, while hex escapes only work inside strings. – Neil – 2016-08-21T23:12:01.517

@Neil: Not exactly, no. You can use them only in identifier names, not as punctuation, comments, whitespaces, keywords or anything else. Have you tried it? It's not like Java :-)

– Bergi – 2016-08-21T23:21:07.680

@Bergi You're right, I'd confused it with Java. Sorry about that. I must have got lucky in this particular case. – Neil – 2016-08-21T23:38:14.473

3

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

Laikoni

Posted 2016-08-21T13:01:16.383

Reputation: 23 676

1With optional newlines allowed, we can get digits like this: main=print$1-1 etc. – Christian Sievers – 2016-08-28T02:56:56.650

Your p program uses p (but can easily be fixed with succ) – Christian Sievers – 2016-08-28T03:07:37.050

3

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.

Emigna

Posted 2016-08-21T13:01:16.383

Reputation: 50 798

3

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.

Interpreter.

My first try was Bubblegum and it didn't work for characters before ?...

jimmy23013

Posted 2016-08-21T13:01:16.383

Reputation: 34 042

3

Perl 6: 921 bytes

Translation of the Python solution.

Each program has the form say "\x<hex escape code>", except:

  • sput "\x73"
  • aput "\x61"
  • yput "\x79"

  • "\x20".say

  • "say chr 34
  • \say chr 92
  • xsay chr 120
  • 0say 1-1
  • 1say 3-2
  • 2 to 9say <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;

smls

Posted 2016-08-21T13:01:16.383

Reputation: 4 352

@sch In Perl 5 that would work, but I tried to do it in Perl 6, where the space after say is required and octal escape sequences are written as \o77. Feel free to post a separate Perl 5 solution... :) – smls – 2016-08-23T12:30:13.090

Sorry, I missed the perl 6 part in your answer. – sch – 2016-08-23T13:16:44.797

2

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*,@

James Holderness

Posted 2016-08-21T13:01:16.383

Reputation: 8 298

2

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

Try it online!

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

Try it online!

Robin Ryder

Posted 2016-08-21T13:01:16.383

Reputation: 6 625

1042 bytes (1136-94) – digEmAll – 2019-08-21T12:13:15.077

@digEmAll Impressive! Deserves a separate answer I think. – Robin Ryder – 2019-08-21T12:29:59.537

no need... it's basically like using of intToUtf8 directly in the string literal – digEmAll – 2019-08-21T12:37:05.883

@digEmAll Still, it shows knowledge of the quirks of the language that I had never heard of until a few minutes ago. – Robin Ryder – 2019-08-21T12:39:29.827

@digEmAll I golfed a feeble 2 bytes by using as.name for c and t. – Robin Ryder – 2019-08-21T17:41:56.147

1as.name printing without the [1] fluff is a good find ! – digEmAll – 2019-08-22T11:42:44.267

2

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

Try it online!

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

Try it online!

1

Similar to zero, this increments the accumulator to get 1.

^o

Try it online!

5

The ASCII code for 5 is 53, so I had to work around this:

6vo

Try it online!

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

Beta Decay

Posted 2016-08-21T13:01:16.383

Reputation: 21 478

2

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

Level River St

Posted 2016-08-21T13:01:16.383

Reputation: 22 049

Why not use V.48 for 0? – Leaky Nun – 2016-08-21T15:43:09.443

@LeakyNun 9 bytes saved, thanks! – Level River St – 2016-08-21T15:56:49.130

Woah, have the V. and P. commands always been there? – Beta Decay – 2016-08-21T18:16:27.553

@βετѧΛєҫαγ Yes but the editor expands them to the full words VDU and PRINT after typing (but they are interpreted without expansion at the BASIC commandline). Most capital letters followed by . will expand into a keyword. This challenge is strict about using nonprintable ASCII but arguably with other challenges you could say the tokenised keywords (ascii 127-255) were one byte. That said I have never tried that argument, and usually give both scores. – Level River St – 2016-08-21T18:58:36.023

@LevelRiverSt I see – Beta Decay – 2016-08-21T19:00:01.473

2

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.

El'endia Starman

Posted 2016-08-21T13:01:16.383

Reputation: 14 504

2

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 - 9print~-<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, nSystem.out<<--'<next char>'
  • t'prin\u0074'(--'u')
  • (print'\u0028'
  • )print'\u0029'
  • 0 - 9print~-<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(++'}')

M. Justin

Posted 2016-08-21T13:01:16.383

Reputation: 151

2

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.

Leaky Nun

Posted 2016-08-21T13:01:16.383

Reputation: 45 011

: in 5: 9P2*c – Mego – 2016-08-22T06:51:53.500

@Mego Thanks, added. – Leaky Nun – 2016-08-22T06:52:38.857

2

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

pajonk

Posted 2016-08-21T13:01:16.383

Reputation: 2 480

Does something like [100 105 115 112] (char-codes) work for disp? – Leaky Nun – 2016-08-22T18:35:34.007

What do you mean exactly? disp([100 105 115 112]) won't produce a string, eval([100 105 115 112]) neither. – pajonk – 2016-08-22T18:42:06.387

You can use fprintf for d ans s: fprintf([115,'']). Saves 2x7 bytes =) Won't make it a winning submission, but hey: 14 bytes is 14 bytes,,, – Stewie Griffin – 2016-08-24T07:27:11.113

Also: disp([0 '']) contains a space. disp([0,'']) doesn't. – Stewie Griffin – 2016-08-24T07:34:53.297

@StewieGriffin Thanks, I missed the space one. Also, thanks for the trick with fprintf. – pajonk – 2016-08-24T13:41:25.870

2

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.

Try it online!

Soren

Posted 2016-08-21T13:01:16.383

Reputation: 285

1I don't think this is a valid answer. First off, you're not allowed to take an input, and second off, this is one program, not 95 programs. The challenge says 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. – James – 2016-08-28T02:46:40.343

@DJMcMayhem Ok, I'll change that – Soren – 2016-08-28T02:48:45.720

DJ is correct. This is blatantly invalid. – Calvin's Hobbies – 2016-08-28T02:50:43.580

@HelkaHomba is my byte count the total of all programs? – Soren – 2016-08-28T02:53:45.543

Yes. And the output is just one character per program, not all of them – Calvin's Hobbies – 2016-08-28T02:54:41.403

@HelkaHomba I believe I fixed it, bbl – Soren – 2016-08-28T03:05:10.397

This doesn't quite work for 5, since 53 contains a 5 (welcome though!) – Sp3000 – 2016-08-28T03:29:23.947

@Sp3000 Fixed! 52‘ is now 49‘‘‘‘ – Soren – 2016-08-28T03:42:34.540

49+4 should work I think. Also 100 can be ȷ2, if you're okay with introducing another non-printable. – Sp3000 – 2016-08-28T04:07:46.477

@Sp3000 ³ is shorter than ȷ2. – Soren – 2016-08-28T04:14:45.033

For some reason, ³ doesn't work? – Soren – 2016-08-28T04:17:05.747

It didnt work because I had 1 empty argument. – Soren – 2016-08-28T04:19:30.440

Oh right, I forgot 100 was built into ³, nice :) – Sp3000 – 2016-08-28T04:22:19.410

By the way, this submission is still noncompetitive by the rules because isn't printable ASCII. I'm not actually sure if Jelly is possible for anything except digits and space using only printable ASCII though (speaking of digits, they can probably be generated easier without come to think of it, eg empty program gives 0) – Sp3000 – 2016-08-28T04:37:44.773

Oh well. This was more of an opportunity to learn Jelly for me than anything else. – Soren – 2016-08-28T04:39:15.963

1

Thanks for fixing it, and welcome to the site! I hope you enjoy it here. Also, just so you know, Jelly uses a custom code page, so in this case it really is 406 chars, even though it would be 503 in UTF-8.

– James – 2016-08-28T04:48:16.353

1

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

mbomb007

Posted 2016-08-21T13:01:16.383

Reputation: 21 944

1

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)

12Me21

Posted 2016-08-21T13:01:16.383

Reputation: 6 110

1

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

user85052

Posted 2016-08-21T13:01:16.383

Reputation:

Why not just have \<char+1>; for everything – Lyxal – 2019-08-18T22:12:04.233

You don't need to escape everything. There are also non-commands in Reg. – None – 2019-08-19T00:54:16.860

(In order to shorten byte count) – None – 2019-08-19T01:54:03.133

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. – Lyxal – 2019-08-19T04:49:21.827

This seems to be the shortest answer right now! – Lyxal – 2019-08-19T10:44:44.323

I will try to re-read the Reg documentation. I might have missed something. – None – 2019-08-20T14:42:27.283

Yes, it is 25. I missed one instruction. – None – 2019-08-20T14:43:24.820

Right, I forgot. – None – 2019-08-20T14:49:27.897

@Jono2906 Marbelous is shorter by 1 byte, but I found a way to golf this program. – None – 2019-08-20T14:53:28.543

Sorry, I became dumb and forgot about the question. – None – 2019-08-20T15:06:27.330

You could just use regular Keg and use maths when characters need to be escaped. – Lyxal – 2019-08-21T01:00:41.073

I think using a nice golfy decrement function is nicer than using maths. – None – 2019-08-21T01:10:56.957

1

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"

Krzysztof Szewczyk

Posted 2016-08-21T13:01:16.383

Reputation: 3 819

1

Pip, 294 295 bytes

Most characters are computed using the Chr operator with their ASCII codes. 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
  • #t takes the length of the builtin for 10, giving 2
  • #h takes the length of the builtin for 100, giving 3
  • #m takes the length of the builtin for 1000, giving 4
  • t/2 gives 5, avoiding using ASCII code 53
  • 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 #t
3 #h
4 #m
5 t/2
6 C54
7 C55
8 C56
9 C57
: 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@0
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

DLosc

Posted 2016-08-21T13:01:16.383

Reputation: 21 213

Your code to output a 'z' uses the character 'z': "z@v" – Florian Bach – 2016-08-22T09:46:35.530

@FlorianBach Fixed – DLosc – 2016-08-22T17:36:20.710

1

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.

Martin Ender

Posted 2016-08-21T13:01:16.383

Reputation: 184 808

1

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

brhfl

Posted 2016-08-21T13:01:16.383

Reputation: 1 291

3You 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 – Delioth – 2016-08-23T17:44:06.010

@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 – brhfl – 2016-08-23T18:18:45.653

@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! – brhfl – 2016-08-24T01:14:34.103

14DP works for 5. Also, I thought it appropriate to link this. – Joe – 2016-08-24T01:42:03.080

And here, dear friend, is a stabler port of dc for Windows. (It's bundled with bc.) :)

– Joe – 2016-08-24T01:57:05.227

@Joe dang, of course! Thanks. & thanks for the link — I was sure I'd done similar things before, and I tried using the 'pseudo-hex' initially only to become convinved I was just remembering things wrong. Friggin' cygwin! – brhfl – 2016-08-24T02:30:12.643

1

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)

seshoumara

Posted 2016-08-21T13:01:16.383

Reputation: 2 878

0

G++, 2970B+1DNP

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

l4m2

Posted 2016-08-21T13:01:16.383

Reputation: 5 985

@JoKing print, put, write, cout all contain t – l4m2 – 2018-11-11T11:14:22.073

@JoKing That's what +1char meant – l4m2 – 2018-11-11T11:21:19.117

0

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.

caird coinheringaahing

Posted 2016-08-21T13:01:16.383

Reputation: 13 702

0

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"

FlipTack

Posted 2016-08-21T13:01:16.383

Reputation: 13 242

0

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

TheOnlyMrCat

Posted 2016-08-21T13:01:16.383

Reputation: 1 079

0

Python3, 2646 characters

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'~'

Steven Hatzakis

Posted 2016-08-21T13:01:16.383

Reputation: 101

write 95 programs, each of which outputs a different one of the 95 printable ASCII characters without that character occurring anywhere in the program. – Jo King – 2019-08-19T08:24:57.243

Thanks @JoKing, I just modified the submission so that there would be 95 programs (each on one line). – Steven Hatzakis – 2019-08-19T08:35:20.043

without that character occurring anywhere in the program – Jo King – 2019-08-19T08:50:50.970

The character doesn't occur in the program (bytes(range(32,33))) – Steven Hatzakis – 2019-08-19T09:07:04.643

I added the output of the program on every other line, or in between program lines to show the output. Note: below the program is on the line denoted with >>> at the start, whereas the output of each line is on the subsequent line below starting with b'output'. – Steven Hatzakis – 2019-08-19T09:07:34.593

1For example, the program for b contains a b. Similarly for the rest of ytes(rang,5) – Jo King – 2019-08-19T09:10:02.677

My program for b, doesn't contain b. Here is the code for it: (bytes(range(98,99))) and which output the following: b'b' – Steven Hatzakis – 2019-08-19T09:11:26.870

Oh? What is the first letter of bytes then? Is it some strange Unicode character that happens to look like a b? – Jo King – 2019-08-19T09:13:26.490

ahh, my apologies! Totally missed that. I guess that would invalidate about 12 characters, but if even things like a parenthesis is an ascii character, are those just considered DNPs? – Steven Hatzakis – 2019-08-19T09:19:01.877

1

Additionally the challenge says: “• The programs must be actual, full programs, according to your language's standard conventions. Functions and REPL snippets are not allowed.”

– manatwork – 2019-08-19T09:33:05.663

Thanks for all the help. It looks like if I manually when through every program and used different program formats (like you noted) wherever there was a conflict, that could be one way to resolve. Regarding snippets, Isn't ord and print(chr(80)) also REPL snippets? (like latter of which was used in the main question as a valid example). – Steven Hatzakis – 2019-08-19T09:43:14.600

REPL snippet is a piece of code that only produces a value and relies on the interpreter's interactive mode to display that value. So the solutions should produce output when put in a file and executed non-interactively like python3 solution.py. If solution.py contains (bytes(range(98,99))), there will be no output, but if contains print(ord(98)), then will be. – manatwork – 2019-08-19T09:49:31.203

Thanks @manatwork, all clear regarding the executable versus interpreter and REPLs. I would need print(bytes(range(98,99))) in the executable, working on it. – Steven Hatzakis – 2019-08-19T10:12:57.697

If I am not mistaken again, I think the version now is correct, I just submitted an overhauled revision that works as source code. – Steven Hatzakis – 2019-08-19T10:55:19.400

Isn't using chr so much shorter for basically every one? Also, why is this marked non-competing? – Jo King – 2019-08-19T11:17:15.953

I thought perhaps it wasn't eligible to compete or the byte/character count would be too high. Will change it now. – Steven Hatzakis – 2019-08-19T11:36:59.847

0

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.

ar4093

Posted 2016-08-21T13:01:16.383

Reputation: 531

0

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.

Draco18s no longer trusts SE

Posted 2016-08-21T13:01:16.383

Reputation: 3 053

0

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

Conor O'Brien

Posted 2016-08-21T13:01:16.383

Reputation: 36 228

0

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!

Business Cat

Posted 2016-08-21T13:01:16.383

Reputation: 8 927

0

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

Destructible Lemon

Posted 2016-08-21T13:01:16.383

Reputation: 5 908

@DJMcMayhem deadfish can only output 10 characters, hence only 10 programs and 85 DNP – Destructible Lemon – 2016-09-02T00:24:53.070

Oh, Okay I misunderstood that. – James – 2016-09-02T00:25:41.143

0

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.

Erik the Outgolfer

Posted 2016-08-21T13:01:16.383

Reputation: 38 134