27
\$\begingroup\$

Write a program that outputs Hell0 W0rld!. It must match this output exactly, including capitalization, zeroes instead of o's, exactly one space, etc. Trailing new lines are allowed.

Lowest score wins. Scoring is based on the sum of the values of each character in the language's code page - otherwise Unicode values should be used. New lines are treated as spaces.

Here are a few example scores:

abc //Score: 294

print(Hell0 W0rld!) //Score: 1597

//Score: 1454
multi
line
code

You can check your ASCII score by inputting your code here. You can view individual ASCII values here.

\$\endgroup\$
3
  • \$\begingroup\$ Tabs are lower than spaces, but I seem to be getting a higher score using tabs. Are whitespace characters taken into account? That would shave a nice chunk off my score(s). \$\endgroup\$
    – ouflak
    Commented Nov 12, 2019 at 11:26
  • \$\begingroup\$ @ouflak Whitespace counts. Only change is that new lines count as spaces. So yes, tabs are cheaper than spaces. \$\endgroup\$
    – Evorlor
    Commented Nov 12, 2019 at 11:43
  • \$\begingroup\$ @Evordor, got it. Thanks. \$\endgroup\$
    – ouflak
    Commented Nov 12, 2019 at 12:05

52 Answers 52

41
\$\begingroup\$

Lenguage, score 0

Well, this is quite boring and obvious, but it seems to achieve the perfect score (assuming I understand the challenge correctly). To fix this loophole, you should probably add the program's length to the sum of the code points; I'm pretty sure that won't break the relative order of the current answers.

The program is

2282524454641945458940768311481012240407465625061984267694778013056442426959468031225640633070772676474431950201473533908

null bytes. Fortunately, 0 multiplied by the number above is still 0.

I believe this decompresses (alternatively, it compresses) to the automatically generated (with the help of a random web page that claims "Original Java program not from me") brainfuck program:

-[------->+<]>-.-[->+++++<]>++.+++++++..[-->+<]>------.[--->++<]>.---[->+++<]>.+[-->+<]>++++.[----->+<]>++.------.--------.-[--->+<]>.

It almost certainly could be golfed (but I haven't tried), but that is unnecessary.

\$\endgroup\$
1
  • 1
    \$\begingroup\$ Since the JavaScript submission was not a serious contender, I've edited it out of the answer. \$\endgroup\$
    – Doorknob
    Commented Dec 20, 2019 at 17:43
16
\$\begingroup\$

05AB1E, score 513 252

-261 points thanks to @Dorian

Posting this separately from my other answer, as this one is arguably less cheating. I've been waiting for somebody else to do this for a while, but nobody did. I tried multiple languages. Pyth has extremely short code for this (Cl"...", if I remember correctly), but it turned out it can't input null bytes, and most other golfing languages I found have painfully large char codes for quotes (and I couldn't write this piece of code in the rest).

"ǝǝǝǝǝǝǝǝǝǝǝǝ...ǝǝǝǝǝ"gтB

Where there are 174047470094320053473995 ǝ characters, that conveniently happen to have a value of 0 in the code page.

Explanation:

"ǝǝǝǝǝǝǝǝǝǝǝǝ...ǝǝǝǝǝ"        push the long string
                      g       pop and get its length
                       тB     push 100 and convert to that base

You definitely shouldn't try the full version online, but you can try online the version with the length finding part skipped.

\$\endgroup\$
3
  • \$\begingroup\$ I make this one 513 too. (I went with the same approach in Jelly for 998 - two different ways. Expensive quotes indeed.) \$\endgroup\$ Commented Oct 20, 2019 at 23:22
  • 1
    \$\begingroup\$ You can also use B to convert the number directly to a string. That will lead to a score of only 252 "ǝǝǝ...ǝǝ"gтB. Try it online \$\endgroup\$
    – Dorian
    Commented Oct 21, 2019 at 7:51
  • \$\begingroup\$ @Dorian Are you sure that can produce a space character? I tried that. UPD: turns out it can; will update slightly later. \$\endgroup\$ Commented Oct 21, 2019 at 9:24
12
\$\begingroup\$

7, 41 characters, code point sum 81

32002453003001200522231203103002440537403

Try it online!

Unlike with many of my 7 programs, there's nothing particularly clever going on here; this basically just prints a string in the simplest possible way (which in 7 involves encoding the string into a piece of source code, evaluating it, analysing the resulting stack element to figure out what source code is most likely to have created it, and then giving the resulting source code directly to the output routines).

The reason this scores so well is that 7 has a code page consisting of only 8 characters, and the code that's used to represent string literals tends to use only 0, 1, 2, 3, 4, 5 (as those commands have much easier-to-analyse effects on the stack than 6 and 7 do, so it's more likely that the original source will be accurately reproduced by the 6 command). This means that none of the code points in the bulk of the program will go above 5 (the assignment of code points to characters in 7 is the obvious one), leading to an average code point value of around 2½ (for this program, happenstance means it's more like 2). Thus, although there are a lot of characters in the program, the sum of the codepoints continues to stay low. (Unlike the Lenguage answer, the code point sum + character count is also very low, so this answer isn't even really cheating.)

\$\endgroup\$
10
\$\begingroup\$

COW, Score: 117799

MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO
MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO
MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO
MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO
MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO Moo MoO MoO
MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO
MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO Moo MoO MoO
MoO MoO MoO MoO MoO Moo Moo OOO MoO MoO MoO MoO MoO MoO MoO
MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO
MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO
MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO Moo MOo MOo MOo
MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo Moo MoO
MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO
MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO
MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO
MoO MoO MoO MoO MoO MoO MoO MoO MoO Moo MOo MOo MOo MOo MOo
MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo
MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo
MOo MOo MOo MOo Moo MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO
MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO
MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO
MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO
MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO Moo MOo MOo MOo
MOo MOo MOo Moo MOo MOo MOo MOo MOo MOo MOo MOo Moo OOO MoO
MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO
MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO
MoO MoO Moo

Try it online!

My cow could not understand that the lower score in this challenge is better, so they scored very high! I kept telling them: "Please score lower, it is better", but they kept responding: "MoO"!

\$\endgroup\$
1
  • 3
    \$\begingroup\$ But the score is a perfect sample input for Is It Double Speak! \$\endgroup\$
    – user85052
    Commented Oct 20, 2019 at 9:12
8
\$\begingroup\$

HTML, Score: 959

Hell0
W0rld!

If newlines (\r and \n) would have been count as their ASCII code (10 and 13) the score would be 937 or 940 because in HTML, new lines in "inline" elements are rendered as space.

\$\endgroup\$
4
  • \$\begingroup\$ How does one "run" a html page? This is the browser parsing a file, not your code actually doing anything :/ \$\endgroup\$
    – Rob
    Commented Oct 21, 2019 at 12:20
  • \$\begingroup\$ @RobQuist, so isn't the browser interpreting my HTML code? \$\endgroup\$
    – Night2
    Commented Oct 21, 2019 at 12:22
  • 4
    \$\begingroup\$ @RobQuist, also please see this: "Answering in non-programming languages is allowed" \$\endgroup\$
    – Night2
    Commented Oct 21, 2019 at 12:26
  • \$\begingroup\$ In my opinion, no, since its not a programming language but markup. \$\endgroup\$
    – Rob
    Commented Oct 21, 2019 at 12:26
7
\$\begingroup\$

Keg, sum = 966 868 853 843

� +HOO��� +�UOG�(�+"

Try it online!

-15 score from cutting out the 0 (with a bit of help from the awful old Python script).

-10 score from A__'s idea to use " and implicit print over the costlier ,.

Based on a comment by Night2, as well as Jo King's old 32-byte quine.

� +HOO��� +�UOG�(�+"        Push the shifted codepoints beginning-first.
� +     � +                 ('H' and 'W' are pushed as sums,
                             because '+' is cheaper than '\'.)
                  +         Add
                 �          29
                   "        then rotate the stack
                (           once for every item on the stack.

If newlines weren't treated as spaces for scoring, this would be 832:


 +GNN���TNF�� +(�+"

Try it online!

\$\endgroup\$
2
  • \$\begingroup\$ Ah, thanks for catching that--my guess was it was some sort of CRLF issue but that didn't explain why the difference is 22. \$\endgroup\$ Commented Oct 20, 2019 at 9:44
  • 1
    \$\begingroup\$ Score: 843. TIO \$\endgroup\$
    – user85052
    Commented Oct 20, 2019 at 13:14
6
\$\begingroup\$

MineFriff, Score: 3725

Cff3,a*a,9*c,a*b4,6*8,8*a7,ff2,8*6,9*c,:a*a1,9*8,`
>l?#;o~

Try it online!

This ain't winning any competitions any time soon I tell you (I dread seeing what Scratch's score would be...). I'll post an image of what this looks like in-game soon, but first I have to actually re-install the python-in-minecraft mod and actually get it all working first.

See y'all soon! (I hope...)

Actual In-Game Progess Report

10 mins in

  • I managed to finally get Forge opened on my mac. That really shouldn't have taken 10 minutes but it did
  • Minecraft 1.8 (unmodded) still hasn't launched/finished downloading.
  • Still downloading the actual mod
  • All star seems like a nice song to listen to while doing this

14 mins in

  • Minecraft 1.8 finally opened
  • Mod finally downloaded
  • All star finished playing
  • Moving on to actually using forge

17 mins in

  • Forge successfully has installed and I'm loading in the mod now
  • Jake Paul is apparently number one. Send help please.

20 mins in

  • Help received. No longer listening to cringey songs
  • I think I've properly installed the mod. No clue if it works because minecraft doesn't want to load.

23 mins in

  • And I downloaded the wrong version of the mod. Oops. Nothing broken, just wasted, oh, I don't know, 6 minutes. Sigh.

27 mins in

  • I still can't read the documentation. Apparently, I needed to drag all the folders from the extracted zip into the mods folder
  • Starting to think about downloading the minefriff world

30 mins in

  • MOD IS FINALLY INSTALLED
  • Thank goodness. Robbie Rotten is now number one. No help needed this time.
  • Time to see if everything still works.

34 mins in

  • About to test if actual interpreter works in-game. Wish me luck!

36 mins in

  • Nup. Game crashed. :(

Tomorrow

  • I'll be trying 1.10 instead of 1.8

Next day, 1 min in

  • Minecraft 1.10 has somehow deleted itself from my list of available installations. Now I have to manually find it somewhere and then somehow get Forge to make a 1.10 profile. Problem is, I won't be able to work on it for another 4 hours. See y'all then!
\$\endgroup\$
2
  • 3
    \$\begingroup\$ Boy, what a journey \$\endgroup\$
    – squid
    Commented Oct 21, 2019 at 16:39
  • 1
    \$\begingroup\$ Cliffhanger!!!! \$\endgroup\$
    – S.S. Anne
    Commented Apr 7, 2020 at 17:52
5
\$\begingroup\$

PHP, Score: 959

"Classic" answer. PHP outputs by default.

Hell0 W0rld!

Try it online!

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

Bash, score: 1360

echo    Hell0   W0rld!

Try it online!

\$\endgroup\$
2
  • 4
    \$\begingroup\$ If you can replace the spaces with tabs, you can save 23*2 = 46 points: tio.run/##S0oszvj/PzU5I5/TIzUnx4Az3KAoJ0Xx/38A - Bash word-splits on any whitespace char. \$\endgroup\$ Commented Oct 21, 2019 at 19:17
  • 1
    \$\begingroup\$ @DigitalTrauma Thanks for the improvment \$\endgroup\$
    – Paul-B98
    Commented Oct 21, 2019 at 19:47
4
\$\begingroup\$

Keg, Score: 1051

Hell0 W0rld\!

Try it online!

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

Zsh, Score 1207

<<<"Hell0 W0rld!"

Try it online, with a self-scorer!

Using <<<Hell0\ W0rld! is shorter, but more expensive: \ = 92, but 2⨯" = 68.

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

Forth (gforth), Score: 1105

." Hell0 W0rld!"

Try it online!

Prints the given string to stdout.

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

bit**, Score: 2519

#72/#101/#108/#108/#48/#32/#87/#48/#114/#108/#100/#33/

Try it online!

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

Japt, Score: 863

")FMM8SME"c+#

Test it

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

Jelly, Score:1213

Just the string. Nothing interesting.

“Hell0 W0rld!

Score: 1744

Simply a compression.

“ØƲṡhḍḊF®Ḍ?»

Try it online!

Code page summator

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

Charcoal, score 722

⍘L”y;;;(...231699726063762276300861 in total...);;;”γ

Port of @someone's 05AB1E answer. Explanation: If you convert 231699726063762276300861 to base 95 using the printable ASCII character set then you get the desired output. Only printable ASCII characters are automatically turned into string literals, so our null bytes have to be quoted with ”y”. Using Charcoal's code page, the special characters have the byte values 148 + 204 + 9 + 121 + 0 + ... + 0 + 9 + 231 = 722.

As proof of concept, you can see it just for the letters He: Try it online!

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

Malbolge, Score: 6087

Just because I can.

('<;_#!7[}4{2VxTv-QsqNo'K+k)"Fgf|Bcc>=O<;(Kq7XXm3TjSng-x+)((`%d#"E~Y|{{>g,;;ut
\$\endgroup\$
2
  • \$\begingroup\$ 6081 is (presumably) your score, but it's not in bytes. You could list the byte count separately for interest if you wanted, or just remove that word. \$\endgroup\$ Commented Oct 22, 2019 at 4:11
  • \$\begingroup\$ Whoops, that was a typo, thanks for noting. \$\endgroup\$ Commented Oct 22, 2019 at 4:15
3
\$\begingroup\$

x86-64 machine code (Linux executable w/ system calls), score 1508

274 bytes: 18 code bytes, 12 data bytes, and 244 zero-padding bytes to make a rel32 = 00 01 00 00 instead of some larger number in the lowest byte.

The natural character-set of x86 machine code is 1 binary byte. No argument can be made for word, unlike with a RISC with fixed-length instructions.

Hexdump of the .text section of the executable (actually from assembling the same thing into a flat binary for hexdump -C). I'm not counting the metadata bytes of the whole executable emitted by the linker.

00000000  8d 35 00 01 00 00 5f 04  0c 92 04 01 0f 05 04 30  |.5...._........0|
00000010  0f 05 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000020  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
00000100  00 00 00 00 00 00 48 65  6c 6c 30 20 57 30 72 6c  |......Hell0 W0rl|
00000110  64 21                                             |d!|
00000112

Disassembly (objdump -d -Mintel).

0000000000400080 <_start>:            # Entry point
  400080:       8d 35 00 01 00 00       lea    esi,[rip+0x100]        # 400186 <msg>

0000000000400086 <_start.lea_ref>:
  400086:       5f                      pop    rdi      # fd = argc = 1
  400087:       04 0c                   add    al,0xc
  400089:       92                      xchg   edx,eax
  40008a:       04 01                   add    al,0x1
  40008c:       0f 05                   syscall         # write(argc=edi, msg=rsi, msglen=rdx) leaves RAX=msglen
  40008e:       04 30                   add    al,0x30
  400090:       0f 05                   syscall         # exit(edi=1)
        ... (a bunch of 00 bytes)

0000000000400186 <msg>:
         48 65  6c 6c 30 20 57 30 72 6c 64 21    db "Hell0 W0rld!"

Note that Linux static executables start with all registers = 0 (except RSP which points to argc on the stack).

add al, imm8 has opcode 04, and is the lowest opcode that takes an immediate. Using that to turn a 0 into a number we want, and xchg-with-eax for another zero, is the best way I've found to construct small numbers under these scoring rules. push imm8/pop is somewhat worse, and mov reg,imm8 has a high opcode.

The opcode map at http://ref.x86asm.net/coder64.html was very useful for this.


Built with nasm -felf64 hell0.asm && ld -o hell0 hell0.o from this source: (Including a mess of commented out possibilities, many with their instruction bytes to remind me why I didn't use them.)

If MSGXOR is %defined to a non-zero value, link with ld -N (aka --omagic) to make .text read+write. In that case, the %if includes a loop that XORs every byte of the string. 0x60 and 0x64 are both equal. Subtraction with 0x30 doesn't save enough, and subtraction with larger values wraps around for too many bytes creating larger bytes.

BITS 64                     ; for flat binary.
%define MSGXOR 0x60

default rel
_start:
    lea    esi,[rel msg]  ; small positive offset.  Truncating the address to 32-bit is ok in a non-PIE
;    mov esi, msg         ; better than   rsi, msg  or strict qword
 .lea_ref:

;    add    al, 1        ; nr_write.  04  add al, imm8 is the lowest-opcode immediate instruction
    ;cmovnz edi, eax     ; 0f 45 f8    RDI is the highest-numbered register, and mode=11 is killer in ModRM
;    xchg   edi, eax          ; 9x
;    mov    edi, [rsp]        ; 8b 3c 24
    pop    rdi                ; 5f      fd = argc=1

;    lea    edx, [rax+msglen]     ; 8d 50 0d
    add    al, msglen
    xchg   edx, eax                ; len = msglen

%if 0
    lea    edi, [rax]   ; 8d 38
    add    edi, eax
    mov    esi, eax
%endif
;    push  "Hell"  ; 68 48 65 6c 6c  ; then would need to deal with 64-bit addresses

;    add cl, msglen    ; 80 c1 0c
;    mov cl, msglen    ; b1 0d

%if MSGXOR != 0
    add al, msglen-2      ; last byte is a '!' which grows when XORed with 0x60
.loop:
    xor byte [rsi+rax], MSGXOR 
    sub eax, strict dword 1      ; longer immediate makes the backwards jcc farther from FF
        ;sub al, 1; 2c 01
    jnc  .loop                   ; }while(rax>=0); jnc has a lower opcode than jge or jns


;    lea ecx, [.loop]     ; at the top: 8d 0d 00 00 00 00       ; loop back with an indirect jump so the loop exit can jump forwards?
;        push  rcx    ; 51
;        ret          ; c3
;       jmp  rcx    ; ff e1   nope, doesn't look good.  Just have to eat the nearly-FF rel8

;    loop .loop   ; e2 f2 
.break:
;;; AL = -1     after the loop
   add    eax, strict dword 2
%else
   add    al, 1                  ; RAX = 1 = _NR_write
%endif
; %else EAX = 0 still

;    add    al, 1 + !!MSGXOR      ; RAX = 1 = _NR_write
;    mov    al, 1
    syscall                      ; write(argc, msg, msglen) returns RAX=msglen

;    xor    al, 60 ^ msglen
    add    al, 60-msglen       ; or sub to wrap to 231 _NR_exit_group?
;    or     al, 60
;    mov    al, 60     ; exit.
;    mov    eax, 60
    syscall

 padbytes equ 0x100 - ($ - .lea_ref)   
 times padbytes   db 0

; in the same section as the code so we can control the rel32 to have one non-zero byte of 01
X equ MSGXOR
;msg: db "Hell0 W0rld!"
msg: db 'H'^X, 'e'^X, 'l'^X, 'l'^X, '0'^X, ' '^X, 'W'^X, '0'^X, 'r'^X, 'l'^X, 'd'^X, '!'  ; last byte not XORed
msglen equ $-msg
;ml: db msglen

;msg: db 0x28, 0x5, 0xc, 0xc, 0x50, 0x40, 0x37, 0x50, 0x12, 0xc, 0x4, 0x41   ; with ^0x60

Score counted with hexdump | awk with a custom format to dump bytes in decimal, and awk to add them up.

nasm hell0.asm -o hell0.bin && 
 <hell0.bin hexdump -e '32/1 "%d " "\n"' |
 awk '{for(i=1; i<=NF; i++)tot+= $i;} END{printf "score = %#x = %d\n", tot, tot}'

With MSGXOR = 0x60, score = 1668, the loop does not pay for itself with this short message, especially with 0 digits instead of o lower-case ASCII. cmp al,imm8 is 3C, but cmp/jcc and counting up towards mslen-1 instead of materializing msglen and msglen-2 separately might help. But it wouldn't help enough; we're 160 score away from break-even.

# with MSGXOR = 0x60
0000000000400080 <_start>:
  400080:       8d 35 00 01 00 00       lea    esi,[rip+0x100]        # 400186 <msg>

0000000000400086 <_start.lea_ref>:
  400086:       5f                      pop    rdi
  400087:       04 0c                   add    al,0xc
  400089:       92                      xchg   edx,eax
  40008a:       04 0a                   add    al,0xa

000000000040008c <_start.loop>:
  40008c:       80 34 06 60             xor    BYTE PTR [rsi+rax*1],0x60
  400090:       2d 01 00 00 00          sub    eax,0x1
  400095:       73 f5                   jae    40008c <_start.loop>

0000000000400097 <_start.break>:
  400097:       05 02 00 00 00          add    eax,0x2
  40009c:       0f 05                   syscall 
  40009e:       04 30                   add    al,0x30
  4000a0:       0f 05                   syscall 
        ...

0000000000400186 <msg>:
  400186:       28 05 0c 0c 50 40      # not really instructions, deleted disassembly
  40018c:       37
  40018d:       50
  40018e:       12 0c 04
  400191:       21                      .byte 0x21

I can't find a way to jump backwards that isn't horrible. Register-indirect jump sucks, and short displacements need a 0xF? byte. Padding with any non-zero byte to change the displacement costs at least as much as it reduces the rel8 displacement, and 00 00 is add [rax], al. Hmm, Possibly with a 256-byte-aligned address in RAX, we could pad with 00 00 without modifying memory? But xchg with EAX is a 9? byte and getting an address into RAX is costly.

But if we have a pointer in RAX, we can't use add al, 1 or sub al, 1 to loop. In 32-bit code we'd have 4? inc/dec, but not RIP-relative addressing. x86-64 inc/dec are terrible, using the ff /0 modrm encoding.

(I considered using a linker script to set the absolute virtual address to something even lower, but LEA's opcode is lower than mov r32, imm32. Hrm, for EAX there is 05 add eax, imm32 with an absolute address. So looping another reg with inc or dec might be viable. Or looping EAX with a pointer-compare, especially if I can make the absolute data address something like 00 00 01 00 just outside the low 64k where Linux disallows memory-mapping by default. But then I'd feel like I had to count the linker script or its resulting metadata. Or if I'm messing around with the metadata (ELF headers) in the executable, maybe have to count the whole thing instead of just the .text section.)

32-bit code needs int 0x80 for system calls, not 0f 05 syscall.

\$\endgroup\$
1
  • \$\begingroup\$ (On 2nd thought, you could maybe argue for scoring x86 instructions as variable-length integers, presumably little-endian.) \$\endgroup\$ Commented Jul 5, 2023 at 12:34
3
\$\begingroup\$

Turing Machine Code, Score: 7105 6279 5175

0   _   !   l   !
!   _   d   l   "
"   _   l   l   #
#   _   r   l   $
$   _   0   l   %
%   _   W   l   &
&   _   _   l   '
'   _   0   l   (
(   _   l   l   )
)   _   l   l   +
+   _   e   l   ,
,   _   H   l   -

Implemented suggestions by Naruyoko
Shaved off another 1100+ using tabs instead of spaces

Try it online!

Turing Machine But Way Worse, Score: 69695 55343

0   0   0   1   1   0   0
0   1   1   1   2   0   0
0   2   0   1   3   0   0
0   3   0   1   4   0   0
0   4   1   1   5   0   0
0   5   0   1   6   0   0
0   6   0   1   7   0   0
0   7   0   1   8   1   0
0   8   0   1   9   0   0
0   9   1   1   10  0   0
0   10  1   1   11  0   0
0   11  0   1   12  0   0
0   12  0   1   13  0   0
0   13  1   1   14  0   0
0   14  0   1   15  0   0
0   15  1   1   16  1   0
0   16  0   1   17  0   0
0   17  1   1   18  0   0
0   18  1   1   19  0   0
0   19  0   1   20  0   0
0   20  1   1   21  0   0
0   21  1   1   22  0   0
0   22  0   1   23  0   0
0   23  0   1   24  1   0
0   24  0   1   25  0   0
0   25  1   1   26  0   0
0   26  1   1   27  0   0
0   27  0   1   28  0   0
0   28  1   1   29  0   0
0   29  1   1   30  0   0
0   30  0   1   31  0   0
0   31  0   1   32  1   0
0   32  0   1   33  0   0
0   33  0   1   34  0   0
0   34  1   1   35  0   0
0   35  1   1   36  0   0
0   36  0   1   37  0   0
0   37  0   1   38  0   0
0   38  0   1   39  0   0
0   39  0   1   40  1   0
0   40  0   1   41  0   0
0   41  0   1   42  0   0
0   42  1   1   43  0   0
0   43  0   1   44  0   0
0   44  1   1   45  0   0
0   45  1   1   46  0   0
0   46  0   1   47  0   0
0   47  0   1   48  1   0
0   48  0   1   49  0   0
0   49  0   1   50  0   0
0   50  1   1   51  0   0
0   51  0   1   52  0   0
0   52  0   1   53  0   0
0   53  0   1   54  0   0
0   54  0   1   55  0   0
0   55  0   1   56  1   0
0   56  0   1   57  0   0
0   57  1   1   58  0   0
0   58  0   1   59  0   0
0   59  1   1   60  0   0
0   60  0   1   61  0   0
0   61  1   1   62  0   0
0   62  1   1   63  0   0
0   63  1   1   64  1   0
0   64  0   1   65  0   0
0   65  0   1   66  0   0
0   66  1   1   67  0   0
0   67  1   1   68  0   0
0   68  0   1   69  0   0
0   69  0   1   70  0   0
0   70  0   1   71  0   0
0   71  0   1   72  1   0
0   72  0   1   73  0   0
0   73  1   1   74  0   0
0   74  1   1   75  0   0
0   75  1   1   76  0   0
0   76  0   1   77  0   0
0   77  0   1   78  0   0
0   78  1   1   79  0   0
0   79  0   1   80  1   0
0   80  0   1   81  0   0
0   81  1   1   82  0   0
0   82  1   1   83  0   0
0   83  0   1   84  0   0
0   84  1   1   85  0   0
0   85  1   1   86  0   0
0   86  0   1   87  0   0
0   87  0   1   88  1   0
0   88  0   1   89  0   0
0   89  1   1   90  0   0
0   90  1   1   91  0   0
0   91  0   1   92  0   0
0   92  0   1   93  0   0
0   93  1   1   94  0   0
0   94  0   1   95  0   0
0   95  0   1   96  1   0
0   96  0   1   97  0   0
0   97  0   1   98  0   0
0   98  1   1   99  0   0
0   99  0   1   100 0   0
0   100 0   1   101 0   0
0   101 0   1   102 0   0
0   102 0   1   103 0   0
0   103 1   1   104 1   1

Tabs instead of spaces, saving over 14,000

Try it online!

\$\endgroup\$
2
  • 1
    \$\begingroup\$ You could probably improve by changing the state name to a much earlier character, and move left instead of right. \$\endgroup\$
    – Naruyoko
    Commented Oct 21, 2019 at 16:30
  • \$\begingroup\$ @Naruyoko, Done, and added a couple of other improvements as well. \$\endgroup\$
    – ouflak
    Commented Nov 12, 2019 at 15:55
3
\$\begingroup\$

C (gcc), Score: 2021

Thanks to GammaFunction

A(){puts("Hell0 W0rld!");}

Also, just for fun, here is a C program that had a score of 1 using overflow. It's a base64 encoded rar file https://pastebin.com/SJMcRnLj

Try it online!

\$\endgroup\$
4
  • \$\begingroup\$ Trailing newlines are allowed, so puts saves a bit. Also, functions are allowed by default unless "full program" is specified in the challenge. \$\endgroup\$ Commented Oct 20, 2019 at 4:05
  • \$\begingroup\$ @GammaFunction how would I make it into a function? \$\endgroup\$
    – girobuz
    Commented Oct 20, 2019 at 4:15
  • 1
    \$\begingroup\$ Like this, using the footer to call the function. I called it A because it's the least expensive valid C identifier. \$\endgroup\$ Commented Oct 20, 2019 at 4:17
  • 1
    \$\begingroup\$ what an interesting year for me to see this answer in \$\endgroup\$
    – Makonede
    Commented Mar 14, 2021 at 19:52
2
\$\begingroup\$

J, Score: 1452

echo'Hell0 W0rld!'

Try it online!

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

evil, Score: 12853

Hard-code the characters

zaeeeaeeewzaeeaeeaeawzuueeueueawzuueeueueawzaeeeaeewzaeeeeewzaeeeeeuewzaeeeaeewzuueeueeaaawzuueeueueawzaeeaeeaewzaeeeeeaw

Try it online!

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

Labyrinth, Score:2151

72.101.108.108.48.32.87.48.114.108.100.33.@

Explanation

72                                          Push ord code of 'H'
  .                                         Output
   101.108.108.48.32.87.48.114.108.100.33.  And so on
                                          @ And exit.

Try it online!

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

MSM, Score: 1465

!dlr0W 0lleH...........

It is great that ! is not an MSM instruction. Half of the program pushes onto stack, half of it concatenates them.

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

brainfuck, score: 5822

++++++++++[>+++++++>++++++++++>+++++++++++>+++++>+++>+++++++++<<<<<<-]>++.>+.>--..>--.>++.>---.<<.<++++++.------.<-.>>>+.

Try it online!

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

Befunge, Score: 1385

"!dlr0W 0lleH">:#,_@

This is my first legitimate code golf so it's probably not the best. Still not sure how the scoring system works. Is lower or higher better?

\$\endgroup\$
3
  • \$\begingroup\$ Lower score is better. \$\endgroup\$ Commented Oct 21, 2019 at 19:04
  • \$\begingroup\$ @pppery thanks, I'm guessing it's the addition of all the ASCII values? \$\endgroup\$
    – Jachdich
    Commented Oct 21, 2019 at 19:17
  • \$\begingroup\$ That understanding is correct. \$\endgroup\$ Commented Oct 21, 2019 at 19:18
2
\$\begingroup\$

80186 machine code (MS-DOS .COM format), score: 1799 (2061 bytes)

Nothing particularly special about this except that I used literal values on the stack to save score over MOV statements. To be able to use the same value for the function number and string location, I used just a little bit of padding.

68 00 09 58 50 5A CD 21 C3
(2039 zeroes) 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
48 65 6C 6C 30 20 57 30 72 6C 64 21 24

TASM (ideal mode) source

IDEAL
P186

MODEL TINY
CODESEG
ORG 100H

MAIN:
    PUSH 0900H
    POP  AX
    PUSH AX
    POP  DX
    INT  21H
    RET

PADDING DB 7F7H DUP (0)
HELLO   DB "Hell0 W0rld!$"

END MAIN
ENDS
\$\endgroup\$
2
  • \$\begingroup\$ Oh the luxury of having a system call that takes implicit-length strings :) Related: my x86-64 Linux version, score 1508. For this, can't you arrange for the offset of HELLO to be 0200h or something, and save 7 score? Also, if your AX has a known value on process entry, you can use 05 add ax, imm16 instead of mov or push. \$\endgroup\$ Commented Oct 22, 2019 at 9:46
  • \$\begingroup\$ Isn't MOV AX, 0900H(B8 00 09) smaller? \$\endgroup\$
    – l4m2
    Commented Apr 9, 2021 at 15:41
2
\$\begingroup\$

HTML, score: 936

Hell0	W0rld!

HTML treats any whitespace as a space.

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

Python 2, Score:1584

Prints the string...

print"Hell0 W0rld!"

Try it online!

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

shortC, Score:1166

ShortC version of this.

AJ"Hell0 W0rld!"

Try it online!

\$\endgroup\$

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.