-4
\$\begingroup\$

Construct a full program which outputs Hello, World!. The score of your submission will be equal to the sum of all of the ASCII values of the distinct characters. The lowest score wins!

Rules

  • It must be a full program which takes no input
  • It must only print to STDOUT, nothing else
  • It must be strictly less than 1000 bytes long
  • It may only include printable ASCII (meaning no \n allowed)
  • The objective is to find the lowest score for every language, so no answer will be marked "accepted"

Example

Here is an example submission in Python, which has a score of 1279:

print"Hello, World!"


Finally, here is a TIO link to score your submission.

\$\endgroup\$
  • 2
    \$\begingroup\$ This answer shows how to write any Python program using only exc="% (which would have a score of 452), but it would be insanely long without newline. \$\endgroup\$ – Surculose Sputum Mar 24 at 4:00
  • \$\begingroup\$ On further thought, the above scheme is impossible without newline :( \$\endgroup\$ – Surculose Sputum Mar 24 at 4:06
  • 1
    \$\begingroup\$ @SurculoseSputum This one uses 9 chars exc%'(1+), no newline. CJam can do it in just 3: ')~. \$\endgroup\$ – Bubbler Mar 24 at 4:12
  • \$\begingroup\$ Would it then be preferrable to include newlines, or maybe add a penalty for solutions which are too long? \$\endgroup\$ – dingledooper Mar 24 at 4:15
  • 2
    \$\begingroup\$ And if you won't change the text "Hello, World!", Stuck will win as always. \$\endgroup\$ – Bubbler Mar 24 at 4:31

21 Answers 21

4
\$\begingroup\$

Stuck, 0 bytes, score 0

An empty program prints "Hello, World!"

Just as suggested in the comments, Stuck wins!

| improve this answer | |
\$\endgroup\$
3
\$\begingroup\$

CJam, 652 bytes, score 120

'))))))))))))))))))))))))))))))))')))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))'))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))'))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))')))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))'))))''(((((((')))))))))))))))))))))))))))))))))))))))))))))))')))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))'))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))'))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))'))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))''((((((

Try it online!

Uses ')(.

| improve this answer | |
\$\endgroup\$
2
\$\begingroup\$

Brain-Flak, 618 bytes, score 265

((((((()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()())()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()())()()()()()()()())()()()()()())[()()()])[()()()()()()()()()()()()()()()()()()()()()()()()])(((((((()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()())()()()()()()()()()()()())()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()())[()()()]))[()()()()()()()])[()()()()()()()()()()()()()()()()()()()()()()()()()()()()()])

Try it online!

Used characters: ()[]

Uses () (one), (...) (sum and push), [...] (negate). Can definitely be shorter by using [] (stack height) but it's not the point of the challenge (as long as the code is under 1000 bytes). Looks like the program can't fit into 1000 bytes using only () and (...).

| improve this answer | |
\$\endgroup\$
2
\$\begingroup\$

C (gcc), 344 \$\cdots\$ 256 254 bytes, score 1624 1575

Lowered score by 49 thanks to Arnauld!!!

h;t;u;a;i;main(c){a=c+c+c;i=a+a;u=i+i;t=u+u+u;h=t+t+t;putchar(t+t);putchar(t+t+u+u+a+c+c);putchar(h);putchar(h);putchar(h+a);putchar(t+i+c+c);putchar(u+u+i+c+c);putchar(t+t+u+a);putchar(h+a);putchar(h+i);putchar(h);putchar(t+t+u+u+a+c);putchar(u+u+i+a);}

Try it online!

Uses characters: ()+;=achimnprtu{}

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ You can get rid of 1 by retrieving it from argc, leading to 1575 points. \$\endgroup\$ – Arnauld Mar 24 at 17:17
  • \$\begingroup\$ @Arnauld Very clever - thanks! :-) \$\endgroup\$ – Noodle9 Mar 24 at 17:24
  • \$\begingroup\$ @Arnauld Why not? Thanks! :-) \$\endgroup\$ – Noodle9 Mar 24 at 17:37
  • \$\begingroup\$ @Arnauld Knocked down to a quarter K - thanks! :-) \$\endgroup\$ – Noodle9 Mar 24 at 17:50
  • \$\begingroup\$ Yeah, that's a nice round figure. And that's why I didn't submit the 254-byte version. ;) \$\endgroup\$ – Arnauld Mar 24 at 17:55
2
\$\begingroup\$

Malbolge, 71 bytes, 3963 points

(=<`#9]=}5YXy1Uvv-Q+q)Mn&Jk#j!EC$dc.?}_<)L'8%oXW2qj|Q@yx+iba'Hd]\E!YX|z

Try it online!

Uses the following unique characters

!#$%&'()+-.12589<=?@CEHJLMQUWXY\]_`abcdijknoqvxyz|}
| improve this answer | |
\$\endgroup\$
2
\$\begingroup\$

Help, WarDoq!, 1 byte, Score: 72

H

Try It Online!

| improve this answer | |
\$\endgroup\$
2
\$\begingroup\$

C (gcc) -zexecstack -Wl,-eA -nostartfiles on Linux x86-64, 876 bytes, score 798

A[]={1111+1111+1111+111+111-11-11-11-11+1+1+1,1111111111+111111111-11111111+1111111+1111111-111111+1111+1111+111+111+111+111+111-11-11-11-11+1+1+1+1+1,111111+111111-11111-1111+111+111+111-11-1-1-1-1-1,111111111+111111111+11111111+11111111+11111111+1111111+1111111+111111-1111-1111-1111-1111-111-111-111+11+11+11+11+1+1+1+1+1,1111111111+1111111111-111111111-111111111-111111111-111111111+11111111+11111111+11111111+11111111-1111111-1111111-1111111-111111-111111-111111+11111+11111-1111+111+111+11+1,111111111+111111111+111111111+111111111+111111111-11111111-1111111-1111111-1111111-1111111-111111-111111+1111+1111+1111+1111+1111-111-111-111+11+11-1-1,1111111111+1111111111-111111111-111111111-111111111-111111111+11111111+11111111+11111111+11111111-1111111-1111111-111111-111111-111111-111111-111111-1111-1111-1111-1111-1111+11+11+11+11+1,11111-1111-1111-111-111-111-11+1+1+1};

Try it online!

Charset: A[]={+,-1};

Same method as the previous answer, with even more hacking to supply a custom entry point named A (which has the smallest ASCII value among a-zA-Z_). Credit to this SO answer for identifying the flags and assembly setup to make this work.

Assembly: (NASM syntax)

bits 64
global _start
_start:
  mov edx, 13
  pop rax
  push rax
  lea rsi, [rel s]
  pop rdi
  syscall
s: db "Hello, World!"

Uses the argc=1 set up on the stack to load the value 1 to rax and rdi. The instructions are slightly mixed up in order to get the minimal code length in C.

Here is the Python script that generates the "ones decomposition" from the xxd -i output (C include-style hex output) of the compiled binary.


C (gcc) -zexecstack on Linux x86-64, 891 bytes, score 1154

main[]={1111+1111+1111+111+111-11-11-11-11+1+1+1,1111111111-111111111-111111111+11111111-1111111-111111-111111-111111-111111+11111-1111-1111-1111-1111+111+111+111+11,1+1+1+1,111111111-11111111-11111111-1111111-1111111-1111111-1111111+111111+111111+111111+111111+11111+11111+11111+11111-111-111-111-111-111-11-11-11,1111111111+1111111111-111111111-111111111-111111111-111111111+11111111+11111111+11111111+11111111-1111111-1111111-1111111+111111+11111+11111+11111+11111-1111-111-111+11+11+11,1111111111+111111111+111111111+111111111+11111111+11111111-1111111-1111111-1111111-1111111-111111-111111-111111-111111-11111-11111-11111-11111-11111+1111+1111+1111+1111-111-111-111-11-1-1-1-1,1111111111+111111111+111111111+111111111+111111111+111111111+11111111+11111111-1111111-1111111-1111111-1111111+111111+111111+111111+11111+11111+11111+11111+11111-1111-1111-1111-1111-111+11-1-1-1-1-1,11+11+11};

Try it online!

Uses ceilingcat's minimal Turing-complete charset main[]={1+,};, plus - to meet the code length limit.

Assembly: (NASM syntax)

bits 64
global _start
_start:
  mov edx, 13
  lea rsi, [rel s]
  mov eax, edi
  syscall
s: db "Hello, World!"

Essentially calls write syscall once, and goes into arbitrary instructions formed by the string literal, causing segfault.

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ This is a brilliant solution (I’ve upvoted it). But I think the language should be "C (gcc)/x86". It won’t work using gcc on a non-x86 machine. \$\endgroup\$ – Mitchell Spector Mar 25 at 13:33
  • \$\begingroup\$ In fact, I just tried it on two x86 machines (one Linux and one OS X), and it failed to print "Hello, World!" on both. I don't know what the difference is between these and TIO, where it worked. \$\endgroup\$ – Mitchell Spector Mar 25 at 14:15
  • \$\begingroup\$ One more comment: This program writes an error message to stderr (when it crashes), which I understood wasn't allowed in OP's specs ("It must only print to STDOUT, nothing else"). I could reduce my dc score, for instance, if spurious output to stderr was allowed, and that's probably true of some of the other solutions as well. \$\endgroup\$ – Mitchell Spector Mar 25 at 14:29
  • \$\begingroup\$ @MitchellSpector This code is supposed to work in x86-64, with executable stack (-zexecstack flag in the compiler/linker). And as pointed out in the linked answer, you might need const in some environments. The error messages are printed by the OS, not the program. \$\endgroup\$ – Bubbler Mar 26 at 0:58
  • \$\begingroup\$ Thanks -- I missed that flag because it wasn't included with the language name in the answer heading, but it's clearly needed. That got it to work correctly on my Linux system. But I still can't get it to work under OS X, where I believe the equivalent compiler option is -Wl,-allow_stack_execute -- but even with that option, it doesn't print "Hello, World!". I tried it with and without the const keyword before main. If you know how to get this to work under OS X, I'd be interested. \$\endgroup\$ – Mitchell Spector Mar 26 at 1:54
1
\$\begingroup\$

brainfuck, 134 score

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.+++++++++++++++++++++++++++++.+++++++..+++.+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.+++++++++++++++++++++++++++++++++++++++++++++++++++++++.++++++++++++++++++++++++.+++.------.--------.-------------------------------------------------------------------.

Try it online!

Alas, could have scored 89 if not for the 1000 character limit.

Boolfuck, 102 score

;;;+;+;;+;+;+;+;+;+;;+;;+;;;+;;+;+;;+;;;+;;+;+;;+;+;;;;+;+;;+;;;+;;+;+;+;;;;;;;+;+;;+;;;+;+;+;+;+;+;;;;+;+;;+;;+;+;;+;;;+;;;+;;+;+;;+;;;+;+;;+;;+;+;+;;;;+;

Try it online!

"Standard".

| improve this answer | |
\$\endgroup\$
1
\$\begingroup\$

Python 2, 574 bytes, score 564

exec"%c"%(111+1)+"%c"%(111+1+1+1)+"%c"%(11+11+11+11+11+11+11+11+11+1+1+1+1+1+1)+"%c"%(11+11+11+11+11+11+11+11+11+11)+"%c"%(111+1+1+1+1+1)+"%c"%(11+11+11+1+1+1+1+1+1)+"%c"%(11+11+11+11+11+11+1+1+1+1+1+1)+"e%c"%(11+11+11+11+11+11+11+11+11+1+1+1+1+1+1+1+1+1)+"%c"%(11+11+11+11+11+11+11+11+11+1+1+1+1+1+1+1+1+1)+"%c"%111+"%c"%(11+11+11+11)+"%c"%(11+11+1+1+1+1+1+1+1+1+1+1)+"%c"%(11+11+11+11+11+11+11+1+1+1+1+1+1+1+1+1+1)+"%c"%111+"%c"%(111+1+1+1)+"%c"%(11+11+11+11+11+11+11+11+11+1+1+1+1+1+1+1+1+1)+"%c"%(11+11+11+11+11+11+11+11+11+1)+"%c"%(11+11+11)+"%c"%(11+11+11+1+1+1+1+1+1)

Try it online!

Used characters: exc"%(1+)

Constructs the string print'Hello, World!' using the characters "%c(1+), then execs it. Using the raw print with any single extra character costs more than this.

| improve this answer | |
\$\endgroup\$
1
\$\begingroup\$

Gol><>, 234 bytes, score 259

llllllll+++l+++++lllllllllllll+++++l++++++++llllllllllll+++++l+l+++++++llllllllllll+++l+++++++++lllllllllll+++l++++++++lllllll++ll++l+++++llll+++l+l+lll++l+$llllllll++++++l++l+llllll+++lll+++++llllllll+++++++lll++l+l+l+llllll++++l++$H

Try it online!

Used characters: l (length of stack), + (add top two numbers), $ (swap top two numbers), H.

$ was needed because some characters (space, H) were impossible to create at that specific stack height; it is cheaper than any number literal (minimum being 0).


Gol><>, 182 bytes, score 315

ssP0ssssssPPPP0ssssssPPPPPPPPPPPP0sssssssPP0ssssssPPPPPPPPPPPPPPP0sssssPPPPPPP0ss0ssPPPPPPPPPPPP0ssssssPPPPPPPPPPPPPPP0ssssssPPPPPPPPPPPP0ssssssPPPPPPPPPPPP0ssssssPPPPP0ssssPPPPPPPPH

Try it online!

Used characters: 0 (push zero to the stack), s (add 16 to top), P (increment top), H (halt and print everything on the stack as characters).

| improve this answer | |
\$\endgroup\$
1
\$\begingroup\$

05AB1E, score: 282 (251 bytes)

0>>>0>>>>>>>>>0>0>>>0>>>>>>>>0>>>>>0>>>0 0>>>>>>0>>>>>>>>0>>>>>>>>0>>>>0>>>>>>>0>>0 0>>>>>>>0>>>0 0>>>>>0>>>>>>>>>0>>0>>>0>0>>>>>>0 0>>>>>>>J 0>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>B

Try it online.

Five characters used: 0> JB

Explanation:

  1. First we construct the number 39138530688472073059231607. We do this per digit, by pushing a 0 and increasing it by 1 per >, after which the entire stack of digits is joined together with J.
  2. Then it pushes another 0 with 107 >s to get the number 107.
  3. After which it will convert 39138530688472073059231607 to base-107 with B, which is "Hello, World!".
| improve this answer | |
\$\endgroup\$
1
\$\begingroup\$

HQ9+, 1 byte, score 72

H

There is no TIO implementation for HQ9+.

| improve this answer | |
\$\endgroup\$
1
\$\begingroup\$

dc, 106 652 192 428 bytes, score 332 272 272 204

11 11+11+11+11+11+1+1+1+1+1+1+P11 11+11+11+11+11+11+11+11+1+1+P11 11+11+11+11+11+11+11+11+1+1+1+1+1+1+1+1+1+P11 11+11+11+11+11+11+11+11+1+1+1+1+1+1+1+1+1+P11 11+11+11+11+11+11+11+11+11+1+P11 11+11+11+P11 11+1+1+1+1+1+1+1+1+1+1+P11 11+11+11+11+11+11+1+1+1+1+1+1+1+1+1+1+P11 11+11+11+11+11+11+11+11+11+1+P11 11+11+11+11+11+11+11+11+11+1+1+1+1+P11 11+11+11+11+11+11+11+11+1+1+1+1+1+1+1+1+1+P11 11+11+11+11+11+11+11+11+1+P11 11+11+P

Try it online!

4 characters used: +1P and the space character.

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ You need to sum the codepoints of all characters you use in your program. \$\endgroup\$ – Third-party 'Chef' Mar 24 at 5:25
  • \$\begingroup\$ @a'_' You're right - I misread the scoring in the challenge. It's fixed. \$\endgroup\$ – Mitchell Spector Mar 24 at 5:29
1
\$\begingroup\$

C (gcc), 540 bytes, score 1563

main(){putchar(11+11+11+11+11+11+1+1+1+1+1+1);putchar(11+11+11+11+11+11+11+11+11+1+1);putchar(11+11+11+11+11+11+11+11+11+1+1+1+1+1+1+1+1+1);putchar(11+11+11+11+11+11+11+11+11+1+1+1+1+1+1+1+1+1);putchar(11+11+11+11+11+11+11+11+11+11+1);putchar(11+11+11+11);putchar(11+11+1+1+1+1+1+1+1+1+1+1);putchar(11+11+11+11+11+11+11+1+1+1+1+1+1+1+1+1+1);putchar(11+11+11+11+11+11+11+11+11+11+1);putchar(11+11+11+11+11+11+11+11+11+11+1+1+1+1);putchar(11+11+11+11+11+11+11+11+11+1+1+1+1+1+1+1+1+1);putchar(11+11+11+11+11+11+11+11+11+1);putchar(11+11+11);}

Try it online!

This is just a straightforward solution that prints the ASCII code of each character in turn, like some of the other solutions here. I'm not aware of any tricky way to reduce the score in C.

| improve this answer | |
\$\endgroup\$
1
\$\begingroup\$

Rust, 35 bytes, Score: 1916

fn main(){print!("Hello, World!")}

I don't know if you can get any shorter in Rust.

| improve this answer | |
\$\endgroup\$
1
\$\begingroup\$

Bash, 18 bytes, score 1005

echo Hello, World!

Try it online!

| improve this answer | |
\$\endgroup\$
1
\$\begingroup\$

H🌍, 2 bytes, score 223

hw

Try it online!

| improve this answer | |
\$\endgroup\$
1
\$\begingroup\$

05AB1E, 15 bytes, score 836

"Hello, World!"

Try it online!

| improve this answer | |
\$\endgroup\$
1
\$\begingroup\$

PHP, 13 bytes, score 802

Hello, World!

Try it online!

| improve this answer | |
\$\endgroup\$
1
\$\begingroup\$

Erlang (escript), 439 bytes, score: 1706

Port of the 540 byte C answer. Unique characters:


main([])->o:fwrte1+,.

Which is of length 23, sum 1706.


main([])->io:fwrite([11+11+11+11+11+11+1+1+1+1+1+1,11+11+11+11+11+11+11+11+11+1+1,11+11+11+11+11+11+11+11+11+1+1+1+1+1+1+1+1+1,11+11+11+11+11+11+11+11+11+1+1+1+1+1+1+1+1+1,11+11+11+11+11+11+11+11+11+11+1,11+11+11+11,11+11+1+1+1+1+1+1+1+1+1+1,11+11+11+11+11+11+11+1+1+1+1+1+1+1+1+1+1,11+11+11+11+11+11+11+11+11+11+1,11+11+11+11+11+11+11+11+11+11+1+1+1+1,11+11+11+11+11+11+11+11+11+1+1+1+1+1+1+1+1+1,11+11+11+11+11+11+11+11+11+1,11+11+11]).

Try it online!

| improve this answer | |
\$\endgroup\$
0
\$\begingroup\$

Python 3, 16 bytes, score 1107

import __hello__

Try it online!

| improve this answer | |
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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