# Hello World 0.0!

source: Dilbert, September 8, 1992

I'm hoping to add a new twist on the classic "Hello World!" program.

Code a program that outputs Hello World! without:

• String/Character literals
• Numbers (any base)
• Pre-built functions that return "Hello World!"
• RegEx literals

With the exceptions of "O" and 0.

†"O" is capitalized, "o" is not acceptable.

• One of [code-golf] and [code-challenge] please, not both. The point of these tags to to help people find questions with the rules they want to use. Essentially every question on this site should be a game of some kind or another. – dmckee Mar 11 '11 at 22:29
• -1 We've already had Obfuscated Hello World, and I think this challenge is too similar. I'd have cast a "close as duplicate" vote, if I weren't a mod. – Chris Jester-Young Mar 11 '11 at 22:35
• @zzzzBov: I don't think it's different enough to warrant another question in the "hello world" theme; a different theme would have been better. But, that's just my opinion. – Chris Jester-Young Mar 11 '11 at 23:39
• I think this is a fine code golf - and better than the prior one. – MtnViewMark Mar 12 '11 at 6:58
• Some people seem to assume that "O"* means they can have a string literal with any number of O’s, including zero. I don’t think that was the intention. Please clarify. – Timwi Mar 12 '11 at 21:12

## Windows PowerShell, way too much

Yes, indeed, back in the day we had to write a »Hello world« using (almost exclusively) zeroes ...

&{-join[char[]]($args|% Length)}  O00000000000000000000000000000000000000000000000000000000000000000000000  O0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000  O00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000  O00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000  O00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000  O0000000000000000000000000000000  O00000000000000000000000000000000000000000000000000000000000000000000000000000000000000  O00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000  O00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000  O00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000  O000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000  O00000000000000000000000000000000  On a more serious note: ## Windows PowerShell, 25 Write-Host Hello World!  No string literal. The Hello World! in there just happens to be parsed as a string since PowerShell is in argument parsing mode there. • How is that real?? O_o – Josh Mar 11 '11 at 22:06 • I searched the internet for some examples or history of this. This is so weird. Could you provide any links? – Caleb Jares Dec 5 '11 at 5:44 • "Back in the day". :) You millennials crack me up 👍 – user63571 Jan 26 '17 at 23:29 • Oh. Unary. I get it. – Matthew Roh Jul 26 '17 at 16:22 ## C, 327 chars #define O(O)-~O #define OO(o)O(O(o)) #define Oo(o)OO(OO(o)) #define oO(o)Oo(Oo(o)) #define oo(o)oO(oO(o)) #define O0 putchar main() { O0(OO(oO(!O0(~O(Oo(OO(-O0(~O(Oo(-O0(O(OO(O0(oo(oO(O0(O(oo(oO(OO(Oo(oo(oO( O0(oo(oo(!O0(O(OO(O0(O0(O(OO(Oo(O0(O(Oo(oo(oO(O0(oo(oo(oO(oo(oo(0)))))))) )))))))))))))))))))))))))))))))))))))); }  Strangely, it does't lose its beauty after preprocessing: main() { putchar(-~-~-~-~-~-~-~-~-~-~!putchar(~-~-~-~-~-~-~-~-putchar(~-~-~-~-~-~- putchar(-~-~-~putchar(-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~putchar( -~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ -~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~putchar(-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ -~-~-~-~-~-~-~-~-~-~-~-~-~!putchar(-~-~-~putchar(putchar(-~-~-~-~-~-~-~putchar (-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~putchar(-~-~-~-~-~- ~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~- ~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~0)))))))))))); }  • Awesome. Missing the !, though. – Mark Reed Nov 21 '13 at 15:07 • This is real art! – Askaga Feb 7 '14 at 19:42 • I feel like the body could be shortened with even more preprocessors. Not sure if the code as a whole would benefeit though. – Zwei Oct 27 '16 at 3:37 • @Zwei, It's certainly possible to shorten it. I made no effort to find the optimal set of macros. – ugoren Oct 27 '16 at 7:59 • Why don't you include the parens in the CLANG #define? would save a few bytes, no? Edit: nevermind, just tried and now I see why that won't work ahaha – Albert Renshaw Jan 24 '17 at 18:15 ## BrainFuck, 102 111 characters ++++++++[>++++[>++>+++>+++>+<<<<-]>+>->+>>+[<]<-]>>.>>---.+++++++..+++.>.<<-.>.+++.------.--------.>+.  Meets all of the rules. Credit goes to Daniel Cristofani. • I can't decide if the rules should also state 0 and/or "O" must be used. It's a little mean to BrainFuck and golfscript, but they don't exactly have a hard time with this challenge. – zzzzBov Mar 11 '11 at 21:32 • @zzzzBov: If they must be used, then Brainfuck code will just include them. They don't affect the program at all, though. – Joey Mar 11 '11 at 21:47 # C, 182 bytes #define decode(c,o,d,e,g,O,l,f) e##c##d##o #define HelloWorld decode(a,n,i,m,a,t,e,d) #define Puzzles(flog) #flog #define CodeGolf Puzzles(Hello World!) HelloWorld(){puts(CodeGolf);}  • +1,Lol,You still using the token pasting operator trick! Nice mate :-) – Quixotic Mar 12 '11 at 7:52 ## C program - 45 (cheating) Lexically, this doesn't use any string literals or regex literals. It takes advantage of the stringification feature of the C preprocessor. s(x) is a macro that turns its argument into a string. #define s(x)#x main(){puts(s(Hello World!));}  • For a very convenient notion of "lexically" :) But cheekiness FTW! – J B Mar 12 '11 at 22:39 ## Haskell - 143 characters o%y=o.o.o$y;o&y=(o%)%y;o!y=o$o$(o%)&y
r=succ;w=pred;a=r%y;e=r$w&l;l=r!'O';o=r e;u=(w&)&a;y=r%l main=putStrLn[w!o,o,l,l,y,w u,w$r&'O',y,a,l,e,u]


oy, that was woolly!

No numbers, no numeric operations, variables renamed for amusement.

Some exposition might be nice:

• o%y, o&y, and o!y each applies the function o to y multiple times: 3, 9, and 29 times respectively. 29?!?! Yes, 29!
• r and w are next and previous character, which when applied using the above higher- order functions can be made to get all the characters needed from 'O'.

The sequence of jumps needed is:

'O' +29    -> 'l'
'O'  +9 -1 -> 'W'
'l'  -9 +1 -> 'd'
'l'  +3    -> 'o'
'd'  +1    -> 'e'
'o'  +3    -> 'r'
'e' -29    -> 'H'
'r' -81    -> '!'
'!'  -1    -> ' '


• Edit: (134 -> 144) Forgot to output an exclamation point, sigh....
• Edit: (144 -> 143) Removed a unnecessary $, renamed # to ! for Hugs. • o rly? o.o .... – Joey Adams Mar 12 '11 at 7:12 • It doesn't work. codepad.org/lyKyj1Ox – nyuszika7h Mar 13 '11 at 15:31 • @Nyuszika7H That's because this service turns on some compiler options by default. It should compile with plain GHC. – FUZxxl Mar 13 '11 at 16:10 • @Nyuszika7H It works just fine with GHC. The problem is that that service is using Hugs from 2006. There appear to be two things that Hugs can't deal with: 1) Using '#' as an operator. Changing to '!' makes it work. 2) The definitions of r=succ and w=pred run afoul of how Hugs implements the monomorphism restriction. Changing to r x=succ x and w x=pred x makes it work (at the cost of 4 characters). These seem to be problems in Hugs. – MtnViewMark Mar 13 '11 at 18:09 • Is it still valid after the @Community edit? – Hosch250 Feb 21 '14 at 23:58 # Unary, 10197 1137672766964589547169964037018563746793726105983919528073581559828 bytes I'm surprised that no one's done this yet... It's too long to post here, but it's 1137672766964589547169964037018563746793726105983919528073581559828 zeroes. Or, more easily read: ~1067 zeroes. Thanks to @dzaima for saving 10197 bytes • When I read "I once wrote an entire database using only zeroes", my first thought was "he must have done it in unary". +1 for being the only answer to work exactly how the comic did – Cyoce Oct 17 '16 at 23:45 ## Mathematica 12 chars Only symbols, no strings. Hello World!  The ! is a factorial operator, but as the symbols Hello and World are undefined, returns the input unchanged. If we modify the program a bit: Hello=2; World=3; Hello World!  Then it prints 12 (2 * 3!) ## i386 assembly (Linux, gcc syntax), 440442 435 Today's my assembly day, and after that I'll have had enough for a while. I allowed myself number 128, see below program for discussion of why. Nothing extraordinary: I'm just encoding "Hello World!" as assembly opcodes where that made sense without numeric constants, and filled in the rest with arithmetic. #define M mov M$0,%ecx;inc %cx;M %ecx,%ebx;inc %cx;M %ecx,%eax;add %ax,%ax
M %ecx,%edx;shl %cl,%dx;M (e),%ch;add %dl,%ch;dec %ch;M %ch,(l)
M %ch,(j);M %ch,(z);M $0,%ch;shl %cl,%edx;M %dl,(s);inc %dl M %dl,(b);M (o),%dl;M %dl,(u);add %al,%dl;dec %dl;M %dl,(r) M$m,%ecx;M $n,%edx;int$c;M %ebx,%eax;M $0,%ebx;int$c
.data
m:dec %eax;e:gs;l:es;j:es;o:outsl (%esi),(%dx)
s:es;push %edi;u:es;r:es;z:es;fs;b:es;n=.-m
t=(n+n)/n;c=t<<(t*t+t)


(assemble with gcc -nostartfiles hello.S -o hello, possibly -m32 depending on your arch)

Why the tolerance for 128? I need syscalls to actually show anything; Linux syscalls are on INT 80h (128 decimal); the only operand format for INT is immediate, so it's not possible to have anything else than a constant (to the code) there. I could (after I get sober) attempt to express it as a function of other symbolic constants in the code, likely n, but that's getting very boring for not much gain. I read the constraint on numbers as a way to prevent ASCII coding, and that's definitely not what I'm doing here, so I feel innocent enough to submit this. (FWIW, I also tried self-modifying code, but that segfaulted) There's now no 128 left either. The code's pure!

• Edit1 reformatted to save lines; removed a numeric 1 (nobody noticed?!)
• Edit2 compressed mov with CPP macros; eliminated the remaining 128.
• This is how real men program. – Nit Mar 4 '14 at 17:30

# Javascript - 305

A bit long but I like the method used.

O=0;O++;O=O.toString();alert([O+0+0+O+0+0+0,0+O+O+0+0+O+0+O,O+O+0+O+O+0+0,O+O+0+O+O+0+0,O+O+0+O+O+O+O,O+0+0+0+0+0,O+0+O+0+O+O+O,O+O+0+O+O+O+O, O+O+O+0+0+O+0,O+O+0+O+O+0+0,O+O+0+0+O+0+0,O+0+0+0+0+O].map(function(e){O=0;O++;O++;return String.fromCharCode(parseInt(e,O))}).reduce(function (a,b){return a+b}))

• I like it. It would be better with function parameters as OO, OOO, but of course that would make it longer. – zzzzBov Mar 12 '11 at 19:31
• Really nice. Does the ',new String()' need to be there at the end? It seems to work without it. – Stephen Perelson Mar 12 '11 at 23:32
• Ah, no it doesn't. Sometimes I forget just how weakly typed Javascript is. – david4dev Mar 12 '11 at 23:38
• You don't need left 0 bits ('0+') either, and the space and the exclamation have two left 0 bits. Total reduction of 28 characters. – Stephen Perelson Mar 12 '11 at 23:50

# C# (131 chars)

141 chars 142 chars

enum X{Hello,World,A,B=A<<A<<A}class Y{static void Main(){var c=(char)X.B;System.Console.Write(X.Hello.ToString()+c+++X.World+c);}}


// Define some constants (B = 32)
enum X { Hello, World, A, B = A << A << A }
class Y
{
static void Main()
{
// Generate the space (character #32)
var c = (char) X.B;

// Remember that “!” is character #33
System.Console.Write(X.Hello.ToString() + c++ + X.World + c);
}
}

• this is twisted and nice. I love it. – jcolebrand Mar 14 '11 at 16:33
• +1 nice way to generate certain numbers. Gotta remember that! – Igby Largeman Sep 19 '13 at 6:03
• LINQPad program, 102 chars: enum X{Hello,World,A,B=A<<A<<A}void Main(){var c=(char)X.B;(X.Hello.ToString()+c+++X.World+c).Dump();} – Cœur Jul 8 '14 at 16:10
• .ToString() -> +"" saves some cahrs – Firo Jul 10 '14 at 10:18
• @Firo: ... and breaks the rules. (No string literals allowed.) – Timwi Jul 10 '14 at 13:55

# JavaScript, 88

t=!0<<-~-~-~-~!0
r=[]
for(i in{Hello:"O",World:0})r+=i+String.fromCharCode(t++)


99

### Many thanks to @Timwi for the suggestions

removed ternary operator:

o={Hello:"O",World:0}
t=!0<<-~-~-~-~!0
c=String.fromCharCode
r=c(0)
for(i in o)r+=i+c(t++)


103
aliased String.fromCharCode

o={Hello:"O",World:0}
t=!0<<-~-~-~-~!0
c=String.fromCharCode


117
Switched if-else to ternary operator

o={Hello:"O",World:0},t=!0<<-~-~-~-~!0


125
I'm keeping the "O" just to have an "O" in the program.

o={Hello:"O",World:0},t=!0<<-~-~-~-~!0
for(i in o)if(o[i])r=i+String.fromCharCode(t)


133

o={Hello:"O",World:0},t=!0<<(!0+!0<<!0)+!0
for(i in o)if(o[i])r=i+String.fromCharCode(t)
else r+=i+String.fromCharCode(t+!0)

• @Joey, that's largely the point. – zzzzBov Mar 11 '11 at 23:35
• @Joey, i read on the codegolf meta that one should avoid answering their own question for some time to encourage others to try various different approaches. My plan was to uncomment it in a day or two. – zzzzBov Mar 11 '11 at 23:43
• @Joey, wasn't working on my own machine at the time, and I didn't feel like e-mailing myself the answer when I could just post it in a comment. – zzzzBov Mar 11 '11 at 23:57
• @Joey: "There are only five of those" is wrong. Anyone can suggest an edit. Just click on "edit" between "link" and "flag" and you can see the code. – John Mar 12 '11 at 3:57
• @zzz: "that's largely the point" Anyone can still see it. Anyone can suggest an edit by clicking on "edit" in between "link" and "flag", which will bring up the edit dialog, revealing your code. – John Mar 12 '11 at 3:59

## GolfScript, 63 chars

[0))):O.)?O.*-.O.?+)).O.*+((..O+.O(.O+?.O-O*@.O+O.+$.O.*-).O/]+  What, no GolfScript entry yet? This one uses a single numeric literal 0 and a variable named O (which is used to store the number 3). Everything else is arithmetic and stack manipulation. The string Hello World! is built up from its ASCII codes, character by character. ### Here's how it works: [ # insert start-of-array marker 0))):O # increment 0 thrice to get 3, and save it in the variable O .)?O.*- # calculate 3^(3+1) - 3*3 = 81 - 9 = 72 = "H" .O.?+)) # calculate 72 + 3^3 + 1 + 1 = 72 + 27 + 2 = 101 = "e" .O.*+(( # calculate 101 + 3*3 - 1 - 1 = 101 + 9 - 2 = 108 = "l" . # ...and duplicate it for another "l" .O+ # calculate 108 + 3 = 111 = "o" . # ...and duplicate it for later use O(.O+? # calculate (3-1)^(3-1+3) = 2^5 = 32 = " " .O-O* # calculate (32 - 3) * 3 = 29 * 3 = 87 = "W" @ # pull the second 111 = "o" to the top of the stack .O+ # calculate 111 + 3 = 114 = "r" O.+$        # copy the (3+3 = 6)th last element on the stack, 108 = "l", to top
.O.*-)      # calculate 108 - (3*3) + 1 = 108 - 9 + 1 = 100 = "d"
.O/         # calculate int(100 / 3) = 33 = "!"
]             # collect everything after the [ into an array
+             # stringify the array by appending it to the input string


# Brainfuck, 111 bytes

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


## Algorithm explained

Increment cell 0 to 10 (it will be loop counter)
Repeat 10 times ; will stop at cell 0
Increment cell 1 to 7
Increment cell 2 to 10
Increment cell 3 to 3
Increment cell 4 to 1
Increment cell 1 by 2 and output it ; Thus, output ASCII 72 'H'
etc. for all symbols in 'Hello World!'


## Longer version without loop, 389 bytes:

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

• This is a code-golf puzzle, the point is to make the shortest possible program. Part of that involves posting the length of your code. – zzzzBov Mar 18 '12 at 19:44

## Lua 14497 86 chars

A different approach, based on the fact that table keys are also strings, and the fact that #Hello == #World == 32 == string.byte'\n'

e=#"O"t=e+e for k,v in pairs{Hello=0,World=e}do T=t^#k io.write(k,string.char(T+v))end


145 char solution

• no strings except "O" or 0
• no Regexes
• no pre-built functions

Did delta encoding of the bytes, then some primenumbers etc etc :)

Golfed version:

e=#"O"d=e+e t=d+e v=d+t z=v+t T=t^d*d^t n=0 for l,m in pairs{T,T/t-z,z,0,d,-T-z,z*z+t*d,T/d,d,-d*t,-t^d,-T+v}do n=n+m io.write(string.char(n))end


Commented:

-- without numbers, strings, regex
-- except "O" and 0
e=#"0"
t=e+e --2
d=t+e -- 3
v=d+t -- 5
z=v+t -- 7
n=0
T=t^d*d^t -- 72 = 2^3+3^2
for l,m in pairs{T, --72
T/t-z, -- 29 = 72/2-7
z, --7
0, -- 0
d, -- 3
-T-z, -- -79 = -72 - 7
z*z+t*d, -- 55 = 7*7 + 2*3
T/d, -- 24 = 72/3
d, -- 3
-d*t, -- -6
-t^d, -- -8
-T+v -- -67 = -72+5
} do
n=n+q[k]
io.write(string.char(n))
end


Edit: Changed multiple O strings, and found some more optimalisations.

• "O"* - I think the * was for the footnote, not "any number of O's – RomanSt Mar 12 '11 at 21:13
• Well, regex'ing is what I naturally do :p. Could replace it at the cost of 5 or 3 extra characters for respectively the first and second solution – jpjacobs Mar 12 '11 at 21:33
• But anyway, I'll edit them out, thanks for the heads up – jpjacobs Mar 12 '11 at 21:45
• Hello and World in table constructor are still string literals - that's just a syntatic sugar. – Oleg V. Volkov Dec 21 '15 at 10:00

## Python (126 130)

O=ord("O")
N=O/O
T=N+N
R=N+T
E=T**R
E<<T
print'O'[0].join(chr(c+O)for c in[N-E,E*R-T,_-R,_-R,_,N-_-E-E,E,_,_+R,_-R,E*R-R,T-_-E-E])

• The literal '' is not allowed. – RomanSt Mar 12 '11 at 21:12
• @romkyns: Very true, fixed. – Hoa Long Tam Mar 13 '11 at 0:40
• Not fixed (wrong output). You are probably thinking of [:0]. – WolframH Nov 22 '13 at 15:39

# J, 250

oo=:#a.
o0=:<.o.^0
o0o=:%:%:%:oo
ooo=:p:^:(-*oo)
o=:<.(^^^0)*(^^0)*(^^0)
o00=:o,~(,[)o0(**(**[))o0o
oo0=:*/p:(!0),>:p:!0
echo u:(o0(**(**]))o0o),(ooo ooo ooo(o.o.^^^0)*oo),o00,(+:%:oo),(oo0-~!p:>:>:0),o,(<.-:o.o.^o.^0),(>:p:(]^])#o00),(*:#0,#:oo),oo0


I had entirely too much fun with this one, and I learned a little bit more J to boot. Also, ooo ooo ooo may be the stupidest code I've ever written.

### QR with halfblocks (169) 121 characters

With QR-Code by using UTF-8 Half-blocks characters:

▗▄▄▄▗▄▖▗▄▄▄
▐▗▄▐▝█▙▐▗▄▐
▐▐█▐▝▄ ▐▐█▐
▐▄▄▟▗▗▗▐▄▄▟
▗▗▖▄▞▝ ▗ ▖▄
▟▜ Code ▀▟
▙▀ Golf ▘▚
▗▄▄▄▐▗▘▟▙▝▝
▐▗▄▐▝▀▛▘▘█▖
▐▐█▐▐▖▐▝▖▜▘
▐▄▄▟▗ ▌█▛▗▝  3


Unfortunely, this won't render nicely there. There is a little snippet with appropriate style sheet, but.. No! The language presented here is not HTML! Language presented here is QR Code! (HTML and CSS is used here only to work around presentation bug!)

 body {
font-family: monospace;
line-height:97%;
}
▗▄▄▄▗▄▖▗▄▄▄  <br>
▐▗▄▐▝█▙▐▗▄▐  <br>
▐▐█▐▝▄ ▐▐█▐  <br>
▐▄▄▟▗▗▗▐▄▄▟  <br>
▗▗▖▄▞▝ ▗ ▖▄  <br>
▟▜ Code ▀▟  <br>
▙▀ Golf ▘▚  <br>
▗▄▄▄▐▗▘▟▙▝▝  <br>
▐▗▄▐▝▀▛▘▘█▖  <br>
▐▐█▐▐▖▐▝▖▜▘  <br>
▐▄▄▟▗ ▌█▛▗▝  <br>
<br>

### QR with halfblocks (169)

  ▛▀▀▌▚▝▐▀▌▛▀▀▌
▌█▌▌▖▞▚▚▘▌█▌▌
▌▀▘▌ ▚▛▞ ▌▀▘▌
▀▀▀▘▚▌▙▘▌▀▀▀▘
▄▙▛▚▜▀▄▀█▖▝▄▌
▖▄▄▘▖▄▄▄▟▗ ▀▘
▜Code  golf!▌
▚▟▘▘▝▙▛▚▐▀▖▜▘
▘▘ ▀▛▗▚▗▛▀▌▄
▛▀▀▌▟▌▜▖▌▘█▐▘
▌█▌▌▘█▌▟█▜▙▐
▌▀▘▌▚▌▌█▗▝▌▚▘
▀▀▀▘ ▝▘▘▀▀▀▀▘


Idealy, this could look like:

• Use your smart phone to see this or zbar under linux. (sample: xwd | xwdtopnm | zbarimg /dev/stdin ) – F. Hauri Jan 28 '14 at 21:40
• Isn't Code golf! a character literal? – ugoren Feb 5 '14 at 8:10
• I actually think this answer, though creative, doesn't qualify because it isn't a program. QR is a way to encode data, not a programming language. – ugoren Feb 5 '14 at 9:20
• Also what about languages like postscript, svg or other presentation languages already used there!? A way to encode is a language anyway... I think! – F. Hauri Feb 5 '14 at 10:07
• I used HTML (minus JS) as an example for what's not a language. Same goes for QR. See these criteria. – ugoren Nov 20 '15 at 15:25

## Scala (357423 361 characters)

Not the shortest answer, unfortunately, but hoping to get bonus marks for the most use of 'O' and '0'

def h(){type t=scala.Char;def OO(c:t)={(c-('O'/'O')).toChar};def O(c:t)={OO(OO(OO(c)))};def O00(c:t)={(c+('O'/'O')).toChar};def O0(c:t)={O00(O00(O00(c)))};val l=O('O');val z=O0(O0(O0(O0(O0(O0(O0(O0(O0(O0(O0(0)))))))))));print(OO(O(O('O'))).toString+(OO(O(O(O('O')))).toString+l+l+'O'+OO(z)+O0(O0(O0(OO('O'))))+'O'+O0('O')+l+OO(OO(O(O(O('O')))))+z).toLowerCase)}


Previously:

def h(){type t=scala.Char;print(OO(O(O('O'))).toString+(OO(O(O(O('O')))).toString+O('O')+O('O')+'O'+OO(O0(O0(O0(O0(O0(O0(O0(O0(O0(O0(O0(0))))))))))))+O0(O0(O0(OO('O'))))+'O'+O0('O')+O('O')+OO(OO(O(O(O('O')))))+O0(O0(O0(O0(O0(O0(O0(O0(O0(O0(O0(0)))))))))))).toLowerCase);def OO[Char](c:t)={(c-('O'/'O')).toChar};def O[Char](c:t)={OO(OO(OO(c)))};def O00[Char](c:t)={(c+('O'/'O')).toChar};def O0[Char](c:t)={O00(O00(O00(c)))}}


Old (illegal) version:

def h(){type t=scala.Char;print(""+OO(O(O('O')))+(""+OO(O(O(O('O'))))+O('O')+O('O')+'O'+OO(O(O(O(O(O('0'))))))+O0(O0(O0(OO('O'))))+'O'+O0('O')+O('O')+OO(OO(O(O(O('O')))))+O(O(O(O(O('0')))))).toLowerCase);def O0[Char](c:t)={O00(O00(O00(c)))};def O[Char](c:t)={OO(OO(OO(c)))};def OO[Char](c:t)={(c-('O'/'O')).toChar};def O00[Char](c:t)={(c+('O'/'O')).toChar}}

• I believe the empty string ("") and strings/character literals containing the character zero ('0') are not allowed. Only the string "O" (capital O) and the number 0 are. – Timwi Mar 12 '11 at 22:59
• Bugger. Some editing required then... – Gareth Mar 12 '11 at 23:08

C (or C++) (body segment: 49) (cheating)

when compiling, compile to a binary called Hello\ World\!, the code is:

#include <stdio.h>
#include <string.h>
int main(int i,char**a)
{
int j=i+i,k=j<<j;puts(strrchr(*a,'O'-(k<<j))+i);
}


The strrchr segment is required to remove the full path in the event the program name passed in contains the full path, also no arguments must be passed in..

Typical compile line could be: gcc -o Hello\ World\! foo.c

# C++, 141, 146

First time trying one of these, can probably be improved quite a bit yet:

char o='O'/'O',T=o+o,X=T+o,f=T+X,t=f+f,F=t*f,h=F+F,l=h+t-T,O=l+X;
char c[]={F+t+t+T,h+o,l,l,O,o<<f,h-t-X,O,l+f+o,l,h,0};
cout<<c;


EDIT:

Stole the divide trick from another post, can't believe I didn't think of that :(

• You're technically supposed to include the entire working program in the character count, including things like main, any included libraries, std::, etc etc – Wug Nov 9 '12 at 22:01

a:b:c:f:g:s:j:z=iterate(\x->x+x)$succ 0 y=[f+j,d+a,c+s+h,l,a+b+l,s,f-s+o,o,a+b+o,l,l-f,a+s] [h,e,l,_,o,_,w,_,r,_,d,x]=y main=putStrLn$map toEnum y


I figured pattern matching would give Haskell a huge leg up, in particular because you can initialize powers of two like so:

one:two:four:eight:sixteen:thirty_two:sixty_four:the_rest = iterate (*2) 1


However, as seen in MtnViewMark's Haskell answer (which deserves many many upvotes, by the way) and other answers, better compression can be achieved by using more than just + and -.

## Clojure - 46 chars

(map print(butlast(rest(str'(Hello World!)))))


Note that Hello and World! are symbols, not literals of any kind.

C++

/*
Hello World!
*/
#define CodeGolf(r) #r
#include<iostream>
using namespace std;
int main()
{
char str[*"O"];
freopen(__FILE__,CodeGolf(r),stdin);
gets(str);gets(str);puts(str);
}

• The 100 violates the rule about numbers. Please replace it with something more amusing. – Joey Adams Mar 12 '11 at 23:03
• @joey-adams Thanks for pointing out. Changed that. – fR0DDY Mar 13 '11 at 5:15
• Line 7: error: ISO C++ forbids declaration of 'main' with no type – Nathan Osman Mar 15 '11 at 2:31
• @george-edison Corrected. Though it worked without int on g++ – fR0DDY Mar 15 '11 at 3:07

## PHP – 49 chars

<?=Hello.chr(($a=-~-~-~0).~-$a).World.chr($a.$a);


Changelog:

• (73 -> 86) Forgot to output an exclamation point... sigh
• (86 -> 57) Uses a single variable with incrementing
• (57 -> 51) Changed to use bitwise operators on 0
• (51 -> 49) More bitwise operators
• Pretty sure that the constants would count as string literals because of the conversions. – Kevin Brown Mar 13 '11 at 18:23
• @Bass5098 Thanks for your edit! I approved it. – nyuszika7h Mar 13 '11 at 18:34
• @Bass5098 that doesn't work, you need to have chars 32 and 33, not 21 and 22. <?$a=-~-~-~0;echo Hello.chr($a.$a-1).World.chr($a.$a); works, but it's 54 chars. – zzzzBov Mar 16 '11 at 18:07 • @zzzzBov I could not figure out how to clear the edit initially, and forgot to roll it back once it was approved. – Kevin Brown Mar 16 '11 at 22:52 • whoops, i left the 1 in there. There I go breaking my own rules...<?$a=-~-~-~0;echo Hello,chr($a.~-$a),World,chr($a.$a); is what I should have used, still 54 chars. – zzzzBov Mar 16 '11 at 23:34

# Python, 106

o=-~-~-~0
L=o+o
d,W=-~L,o**o
_=o*W
print str().join(chr(L+W+_-i)for i in[d*L,L+d,L,L,o,-~_,W,o,0,L,d+d,_])

• Use '' (with no preceding space) instead of str() – aditsu Mar 19 '13 at 11:29
• Also, VERY nice! :) Btw, the multiple assignment is not saving any characters – aditsu Mar 19 '13 at 11:39
• @aditsu: I can't, that would be a string literal. Thanks for your comments. :) – flornquake Mar 20 '13 at 14:49
• Oh oops, somehow the empty string didn't register as a literal in my mind – aditsu Mar 20 '13 at 15:23

# Perl, 186 bytes

@A=(0,0,0,0);@B=(@A,@A);@C=(@B,@B);@D=(@C,@C);@E=(@D,@D);@d=(@E,@D,@A);$l=[@d,@B];$o=[@$l,0,0,0];print(chr@$_)for[@E,@B],[@d,0],$l,$l,$o,\@D,[@E,@C,@A,0,0,0],$o,[@$o,0,0,0],$l,\@d,[@D,0]


Each chararcter is printed via its ordinal number, which is the length of an array. The construction of the arrays are optimized via the binary representation of the character numbers.

## Ungolfed:

@A = (0, 0, 0, 0);          # A = 2^2
@B = (@A, @A);              # B = 2^3
@C = (@B, @B);              # C = 2^4
@D = (@C, @C);              # D = 2^5
@E = (@D, @D);              # E = 2^6

# d = 100 = 0x64 = 1100100b
@d = (@E, @D, @A);          # d = 2^6 + 2^5 + 2^2

# l = 108 = 0x6C = 1101100b
$l = [@d, @B]; # l = d + 2^3 # o = 111 = 0x6F = 1101111b$o = [@$l, 0, 0, 0]; # o = l + 3 print (chr @$_) for
[@E, @B],              # "H"    H  =  72 = 0x48 = 1001000b = 2^6 + 2^3
[@d, 0],               # "e"    e  = 101 = 0x65 = 1100101b = d + 1
$l,$l, $o, # "llo" \@D, # " " ' ' = 32 = 0x20 = 0100000b = 2^5 [@E, @C, @A, 0, 0, 0], # "W" W = 87 = 0x57 = 1010111b = 2^6 + 2^4 + 2^2 + 3$o,                    # "o"
[@$o, 0, 0, 0], # "r" r = 114 = 0x72 = 1110010b = o + 3$l, \@d,               # "ld"
[@D,0]                 # "!"    !  =  33 = 0x21 = 0100001b = 2^5 + 1

• seems that my binary vodoo inspired you :) +1 – masterX244 Apr 13 '14 at 18:18

# Java 389 characters

spotted a unnecessary declaration

class A{static int a=0,b=a++,f=a,e=a++;static char p(String s){return(char)Byte.parseByte(s,a);}public static void main(String[]z){long x=e,y=b;String c=((Long)x).toString(),d=((Long)y).toString();char l=p(c+c+d+c+c+d+d),m=p(c+c+d+d+c+d+c),o=(char)(l+a+f),_=p(c+d+d+d+d+d),$=_++;System.out.print(new char[]{p(c+d+d+c+d+d+d),m,l,l,o,$,p(c+d+c+d+c+c+c),o,(char)(o+a+f),l,(char)(m-f),_});}}


History is in edit history now the original ungolfed version readable:

// H  e  l    l   o      W  o  r   l    d  !
//72,101,108,108,111,32,87,111,114,108,100 33
import static java.lang.Integer.*;
class A
{

public static void main(String[] args)
{
Integer a=0,b=a++,e=a++;  // making a 0 a 1 and a 2 which is required later;
String c=e.toString(),d=b.toString(),z=c.substring(0,0);  //

String H = ((char)parseInt(d+c+d+d+c+d+d+d,a))+z+  // make binary values and then to char
(char)parseInt(d+c+c+d+d+c+d+c,a)+
(char)parseInt(d+c+c+d+c+c+d+d,a)+
(char)parseInt(d+c+c+d+c+c+d+d,a)+
(char)parseInt(d+c+c+d+c+c+c+c,a)+
(char)parseInt(d+d+c+d+d+d+d+d,a)+
(char)parseInt(d+c+d+c+d+c+c+c,a)+
(char)parseInt(d+c+c+d+c+c+c+c,a)+
(char)parseInt(d+c+c+c+d+d+c+d,a)+
(char)parseInt(d+c+c+d+c+c+d+d,a)+
(char)parseInt(d+c+c+d+d+c+d+d,a)+
(char)parseInt(d+d+c+d+d+d+d+c,a)
;
System.out.println(H);  //obvious
}


## Perl 6, 199 bytes

my \O=+[0];my \t=O+O;my \T=t+O;my \f=(t+t,O);my \F=t+T;my \S=T+T;my \L=(S,F);
say [~] ((S,T),(|L,t,0),(my \l=(|L,T,t)),l,(my \o=(|l,O,0)),F,(S,|f,t,0),o,(|L,|f),l,(|L,t),(F,0),)
.map({chr [+] t X**@_})


(newlines are added to reduce width, but are unnecessary so are not counted)

Hello World! is encoded as a list of lists of the powers of 2 of each letter.

There is exactly one place where I have a literal 0 that is used for anything other than a 0. It is used to create a one-element list, which is immediately turned into the number 1 with the numeric prefix operator (+[0]).

my \O=+[0];    # one          # (List.elems)
my \t=O+O;     # two
my \T=t+O;     # Three
my \f=(t+t,O); # (four, one)  # <W r>
my \F=t+T;     # five
my \S=T+T;     # six

my \L=(S,F);   # lowercase letter  # (6,5)

say [~] (
(S,T),            # H
(|L,t,0),         # e
(my \l=(|L,T,t)), # l
l,                # l  reuse <l>
(my \o=(|l,O,0)), # o  reuse <l>, add 0,1
F,                # ␠
(S,|f,t,0),       # W
o,                # o  reuse <o>
(|L,|f),          # r
l,                # l  reuse <l>
(|L,t),           # d
(F,0),            # !
).map({chr [+] t X**@_})


# JavaScript 662 chars

O=[[,],[,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,],[,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,],[,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,],[,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,],[],[,,,,,,,,,,,,,,,,],[,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,],[,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,],[,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,],[,,,,,,,,,,,,,,,,,,,,,,,,,,,,,]];for(O_O=[].length;O.length>O_O;O_O++)document.write(String.fromCharCode((O[O_O].length||-Math.pow([,,].length,[,,,,,].length)-[,,,,,,,].length)+Math.pow([,,].length,[,,,,,,].length)+Math.pow(++[,].length,[,,,].length)-[,].length));document.write(String.fromCharCode(Math.pow([,,].length,[,,,,,].length)+[,].length))


What about abusing array literals just to have unary base. This program has advantage of not using 0.

• While this may be valid, this particular puzzle is a code golf, which means you should be aiming for the shortest code possible. At 600+ chars, you're nowhere near the <100 chars that the existing JS solutions already have. – zzzzBov Nov 20 '12 at 15:01
• @zzzzBov: I'm actually not trying to win. – Konrad Borowski Nov 20 '12 at 15:02
• This program has advantage of not using 0. What about O_O=0;? – Erik the Outgolfer Sep 15 '16 at 15:12
• @EriktheGolfer: Fixed, thanks. I failed to notice that one. – Konrad Borowski Sep 17 '16 at 11:15
• O_O=[].length can be written as O_O=false which decreases it by 4. – Atmocreations Oct 26 '16 at 14:54

## protected by a spaghettoDec 30 '15 at 0:41

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).