60
\$\begingroup\$

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

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

print(chr(80))

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

print(chr(112))

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

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

which prints p but does not contain p.

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

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

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

Rules

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

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

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

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

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

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

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

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

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

62 Answers 62

27
\$\begingroup\$

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!

\$\endgroup\$
2
  • \$\begingroup\$ print~-<N+1> doesn't work for 1. You said it works for 0 to 8. \$\endgroup\$ Commented Aug 21, 2016 at 20:36
  • 8
    \$\begingroup\$ @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. \$\endgroup\$
    – Copper
    Commented Aug 21, 2016 at 20:48
22
\$\begingroup\$

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

\$\endgroup\$
5
  • \$\begingroup\$ 39c for '? Also, you're forgetting that single digits can just be that number \$\endgroup\$
    – Sp3000
    Commented Aug 21, 2016 at 13:38
  • 1
    \$\begingroup\$ @Sp3000 they can't because that would include the char you're producing in the input \$\endgroup\$
    – Blue
    Commented Aug 21, 2016 at 13:39
  • \$\begingroup\$ But then use 1) for 2 etc to save one byte there \$\endgroup\$
    – Luis Mendo
    Commented Aug 21, 2016 at 13:39
  • \$\begingroup\$ Sorry, 1) was what I meant yeah \$\endgroup\$
    – Sp3000
    Commented Aug 21, 2016 at 13:40
  • \$\begingroup\$ Also, there's TXYZ \$\endgroup\$
    – Sp3000
    Commented Aug 21, 2016 at 13:43
14
\$\begingroup\$

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

\$\endgroup\$
10
  • 3
    \$\begingroup\$ @βετѧΛєҫαγ Probably since it was mostly copied. \$\endgroup\$ Commented Aug 21, 2016 at 14:27
  • 8
    \$\begingroup\$ @HelkaHomba I mean, BF constants are basically the shortest from what I know. Trying to do it yourself on already established constants is pointless. \$\endgroup\$
    – Insane
    Commented Aug 22, 2016 at 6:25
  • 3
    \$\begingroup\$ --[>-<---]>[<->--]<[->-<]>. works for output +. \$\endgroup\$
    – Dennis
    Commented Aug 27, 2016 at 23:31
  • 3
    \$\begingroup\$ @Dennis A bit of bashing later: -----[[----<]>>-]<. \$\endgroup\$
    – Sp3000
    Commented Aug 28, 2016 at 6:03
  • 2
    \$\begingroup\$ Also +[+[+>]<<++++]>. \$\endgroup\$
    – Sp3000
    Commented Aug 28, 2016 at 6:08
13
\$\begingroup\$

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

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!

\$\endgroup\$
5
  • 4
    \$\begingroup\$ I love the random class B for printing A \$\endgroup\$
    – Tas
    Commented Aug 23, 2016 at 5:43
  • \$\begingroup\$ 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. ;) \$\endgroup\$ Commented Aug 23, 2016 at 6:51
  • 2
    \$\begingroup\$ Btw, 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. \$\endgroup\$ Commented Aug 23, 2016 at 7:13
  • \$\begingroup\$ @KevinCruijssen Thanks! I'm working on reworking it now. \$\endgroup\$
    – Copper
    Commented Aug 23, 2016 at 13:30
  • \$\begingroup\$ n: Forgot to escape print \$\endgroup\$ Commented Aug 23, 2016 at 21:31
10
\$\begingroup\$

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
\$\endgroup\$
3
  • \$\begingroup\$ @LuisMendo I'm still counting 297 \$\endgroup\$
    – DJMcMayhem
    Commented Aug 21, 2016 at 15:13
  • \$\begingroup\$ @LuisMendo I count 297 also. \$\endgroup\$
    – Leaky Nun
    Commented Aug 21, 2016 at 15:15
  • \$\begingroup\$ Sorry, my mistake \$\endgroup\$
    – Luis Mendo
    Commented Aug 21, 2016 at 16:35
8
\$\begingroup\$

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

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.

\$\endgroup\$
6
  • \$\begingroup\$ For the octal escapes you can use ?\xxx instead of "\xxx" for 1 byte each. \$\endgroup\$
    – Jordan
    Commented Aug 21, 2016 at 15:15
  • \$\begingroup\$ Why p 1+8 and not p-~8 ? \$\endgroup\$
    – Cyoce
    Commented Aug 21, 2016 at 18:03
  • \$\begingroup\$ @Cyoce Ruby interprets that as binary -, or something. :( \$\endgroup\$
    – lynn
    Commented Aug 21, 2016 at 18:19
  • \$\begingroup\$ @Jordan Noted, but I’m lazy… feel free to make the edit/recount n_n \$\endgroup\$
    – lynn
    Commented Aug 21, 2016 at 18:19
  • 3
    \$\begingroup\$ You can do most of these shorter with putc 65 => A \$\endgroup\$
    – histocrat
    Commented Aug 28, 2016 at 2:59
7
\$\begingroup\$

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
\$\endgroup\$
5
  • 1
    \$\begingroup\$ This format is less helpful than the other answers' format, in my opinion \$\endgroup\$
    – Leaky Nun
    Commented Aug 21, 2016 at 13:56
  • \$\begingroup\$ @LeakyNun Do you mean to group them by method? There are quite a few exceptions. \$\endgroup\$
    – Adám
    Commented Aug 21, 2016 at 13:58
  • 2
    \$\begingroup\$ These 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. \$\endgroup\$ Commented Aug 21, 2016 at 13:59
  • \$\begingroup\$ @HelkaHomba Oops, I didn't notice that requirement. \$\endgroup\$
    – Adám
    Commented Aug 21, 2016 at 14:09
  • 1
    \$\begingroup\$ is my new favorite smiley \$\endgroup\$ Commented Aug 21, 2016 at 20:10
6
\$\begingroup\$

PHP -r (891 680 674 bytes, 2 0 DNP)

Edit: saved 203 bytes thanks to jimmy23013 and implemented the 2 DNP thanks to Mego


This answer heavily abuses PHP's generous nature. Most of the cases take one of these forms (7 bytes each):

<?=Y^x;
<?=Z&e;
<?=V|Z;

PHP converts the letters on either side of the operator to strings, then performs the appropriate bitwise operation by converting each string to its ASCII character value, and finally converts the result back to a character.

In the first example above, Y^x becomes 89^78. The result of this is 33, which is then sent to STDOUT as the character !.

A script was written to bruteforce all possible combinations: the results can be found here.


Exceptions:

; is <?=Z^a?> (8 bytes)
| is <?='9'^E; (9 bytes)

< and ? would normally be DNP due to the required start tag, but by using the -r flag, code can be executed without them:

< is echo Z^f; (9 bytes)
? is echo Z^e; (9 bytes)
= is echo Z^g; (9 bytes)


Score:

(7 * 90) + 8 + 9 + 9 + 9 + 9 = 674 bytes

\$\endgroup\$
10
  • \$\begingroup\$ @jimmy23013 Whoops, I misread the documentation. \$\endgroup\$
    – user45941
    Commented Aug 23, 2016 at 9:54
  • \$\begingroup\$ You can use & | ^ between two letters to generate all printable ascii characters except <?=|;. \$\endgroup\$
    – jimmy23013
    Commented Aug 23, 2016 at 10:01
  • \$\begingroup\$ @jimmy23013 That's bonkers. Just when I thought I'd learnt all the quirks of PHP! \$\endgroup\$
    – Clamburger
    Commented Aug 23, 2016 at 14:50
  • 1
    \$\begingroup\$ many 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. \$\endgroup\$ Commented Aug 23, 2016 at 21:35
  • 1
    \$\begingroup\$ @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. \$\endgroup\$
    – Clamburger
    Commented Aug 24, 2016 at 0:21
5
\$\begingroup\$

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.

\$\endgroup\$
2
5
\$\begingroup\$

><>, 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;
\$\endgroup\$
4
  • \$\begingroup\$ Your ; uses ;. Also, I'm fairly sure most of these can be golfed by erroring out, and o is definitely possible. \$\endgroup\$
    – Sp3000
    Commented Aug 21, 2016 at 17:52
  • \$\begingroup\$ @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? \$\endgroup\$
    – DanTheMan
    Commented Aug 21, 2016 at 18:05
  • \$\begingroup\$ 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. \$\endgroup\$
    – Sp3000
    Commented Aug 21, 2016 at 18:08
  • \$\begingroup\$ @Sp3000 I fixed the ; program though. Thanks for pointing that out! \$\endgroup\$
    – DanTheMan
    Commented Aug 21, 2016 at 18:09
5
\$\begingroup\$

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

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

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.

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

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

\$\endgroup\$
4
\$\begingroup\$

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]

\$\endgroup\$
1
  • 2
    \$\begingroup\$ The 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. \$\endgroup\$ Commented Aug 22, 2016 at 12:01
4
\$\begingroup\$

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
\$\endgroup\$
2
  • \$\begingroup\$ 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? \$\endgroup\$
    – Leo
    Commented Mar 1, 2018 at 22:38
  • \$\begingroup\$ @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. \$\endgroup\$ Commented Mar 1, 2018 at 23:15
4
\$\begingroup\$

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

\$\endgroup\$
2
  • 1
    \$\begingroup\$ With optional newlines allowed, we can get digits like this: main=print$1-1 etc. \$\endgroup\$ Commented Aug 28, 2016 at 2:56
  • \$\begingroup\$ Your p program uses p (but can easily be fixed with succ) \$\endgroup\$ Commented Aug 28, 2016 at 3:07
3
\$\begingroup\$

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

\$\endgroup\$
3
\$\begingroup\$

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.

\$\endgroup\$
7
  • \$\begingroup\$ "x" needs special handling, too. Also, use alert(atob`XA`) for "\" to save a few bytes. \$\endgroup\$
    – GOTO 0
    Commented Aug 21, 2016 at 17:11
  • \$\begingroup\$ @GOTO0 Ugh, I can't believe I forgot x. \$\endgroup\$
    – Neil
    Commented Aug 21, 2016 at 17:56
  • 1
    \$\begingroup\$ Javascript allows \u escapes in source code? Cool \$\endgroup\$
    – Cyoce
    Commented Aug 21, 2016 at 18:54
  • \$\begingroup\$ @Cyoce: In identifiers, yes, in general, no. \$\endgroup\$
    – Bergi
    Commented Aug 21, 2016 at 23:02
  • \$\begingroup\$ @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. \$\endgroup\$
    – Neil
    Commented Aug 21, 2016 at 23:12
3
\$\begingroup\$

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.

\$\endgroup\$
3
\$\begingroup\$

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;
\$\endgroup\$
2
  • \$\begingroup\$ @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... :) \$\endgroup\$
    – smls
    Commented Aug 23, 2016 at 12:30
  • \$\begingroup\$ Sorry, I missed the perl 6 part in your answer. \$\endgroup\$
    – sch
    Commented Aug 23, 2016 at 13:16
3
\$\begingroup\$

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!

\$\endgroup\$
16
  • 1
    \$\begingroup\$ I 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. \$\endgroup\$
    – DJMcMayhem
    Commented Aug 28, 2016 at 2:46
  • \$\begingroup\$ @DJMcMayhem Ok, I'll change that \$\endgroup\$
    – Aly
    Commented Aug 28, 2016 at 2:48
  • \$\begingroup\$ DJ is correct. This is blatantly invalid. \$\endgroup\$ Commented Aug 28, 2016 at 2:50
  • \$\begingroup\$ @HelkaHomba is my byte count the total of all programs? \$\endgroup\$
    – Aly
    Commented Aug 28, 2016 at 2:53
  • 1
    \$\begingroup\$ 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. \$\endgroup\$
    – DJMcMayhem
    Commented Aug 28, 2016 at 4:48
3
\$\begingroup\$

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!

\$\endgroup\$
6
  • \$\begingroup\$ 1042 bytes (1136-94) \$\endgroup\$
    – digEmAll
    Commented Aug 21, 2019 at 12:13
  • \$\begingroup\$ @digEmAll Impressive! Deserves a separate answer I think. \$\endgroup\$ Commented Aug 21, 2019 at 12:29
  • \$\begingroup\$ no need... it's basically like using of intToUtf8 directly in the string literal \$\endgroup\$
    – digEmAll
    Commented Aug 21, 2019 at 12:37
  • \$\begingroup\$ @digEmAll Still, it shows knowledge of the quirks of the language that I had never heard of until a few minutes ago. \$\endgroup\$ Commented Aug 21, 2019 at 12:39
  • 1
    \$\begingroup\$ as.name printing without the [1] fluff is a good find ! \$\endgroup\$
    – digEmAll
    Commented Aug 22, 2019 at 11:42
2
\$\begingroup\$

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
\$\endgroup\$
5
  • \$\begingroup\$ Why not use V.48 for 0? \$\endgroup\$
    – Leaky Nun
    Commented Aug 21, 2016 at 15:43
  • \$\begingroup\$ @LeakyNun 9 bytes saved, thanks! \$\endgroup\$ Commented Aug 21, 2016 at 15:56
  • \$\begingroup\$ Woah, have the V. and P. commands always been there? \$\endgroup\$
    – Beta Decay
    Commented Aug 21, 2016 at 18:16
  • \$\begingroup\$ @βετѧΛєҫαγ 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. \$\endgroup\$ Commented Aug 21, 2016 at 18:58
  • \$\begingroup\$ @LevelRiverSt I see \$\endgroup\$
    – Beta Decay
    Commented Aug 21, 2016 at 19:00
2
\$\begingroup\$

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.

\$\endgroup\$
2
\$\begingroup\$

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(++'}')
\$\endgroup\$
0
2
\$\begingroup\$

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

\$\endgroup\$
2
\$\begingroup\$

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
\$\endgroup\$
5
  • \$\begingroup\$ Does something like [100 105 115 112] (char-codes) work for disp? \$\endgroup\$
    – Leaky Nun
    Commented Aug 22, 2016 at 18:35
  • \$\begingroup\$ What do you mean exactly? disp([100 105 115 112]) won't produce a string, eval([100 105 115 112]) neither. \$\endgroup\$
    – pajonk
    Commented Aug 22, 2016 at 18:42
  • \$\begingroup\$ 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,,, \$\endgroup\$ Commented Aug 24, 2016 at 7:27
  • \$\begingroup\$ Also: disp([0 '']) contains a space. disp([0,'']) doesn't. \$\endgroup\$ Commented Aug 24, 2016 at 7:34
  • \$\begingroup\$ @StewieGriffin Thanks, I missed the space one. Also, thanks for the trick with fprintf. \$\endgroup\$
    – pajonk
    Commented Aug 24, 2016 at 13:41

Your Answer

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

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