| Bytes | Lang | Time | Link |
|---|---|---|---|
| 087 | Python 3 | 250529T040502Z | Lucenapo |
| 015 | Vyxal 3 | 240208T160754Z | pacman25 |
| 184 | YASEPL | 240208T151557Z | madeforl |
| 102 | Swift | 230715T011453Z | macOSist |
| 022 | ForWhile | 230712T173632Z | bsoelch |
| 180 | Python | 230712T134740Z | The Empt |
| nan | 230531T174848Z | Dadsdy | |
| 186 | Javascript | 131119T023540Z | wolfhamm |
| 034 | Arturo | 230507T064217Z | chunes |
| 045 | Julia 1.0 | 211015T134940Z | MarcMush |
| 1245 | Pascal FPC | 211014T193426Z | sech1p |
| 131 | Microsoft Excel | 200615T191844Z | General |
| 035 | APL Dyalog Unicode | 191028T235914Z | Adá |
| 094 | Runic Enchantments | 190916T175922Z | Draco18s |
| 166 | JavaScript | 190916T163345Z | Naruyoko |
| 014 | Keg | 190915T045736Z | user8505 |
| 038 | Forth gforth | 180824T182315Z | reffu |
| 103 | F# | 180814T133921Z | Ciaran_M |
| nan | Unary | 141122T193401Z | Beta Dec |
| 062 | Tcl | 180430T001923Z | sergiol |
| nan | Lenguage | 170726T154110Z | V. Court |
| 037 | Unlambda | 170625T092843Z | celtschk |
| 111 | Brainfuck | 120318T181921Z | Michael |
| 177 | C | 170423T081702Z | jdt |
| 182 | C | 110312T074002Z | fR0DDY |
| 079 | JavaScript ES5 | 170128T140753Z | Luke |
| 157 | PHP | 170127T114332Z | Titus |
| 016 | ZX Spectrum BASIC | 170127T130929Z | Radovan |
| 136 | PHP | 170127T122505Z | Titus |
| nan | 170127T094929Z | Shaun Be | |
| nan | Windows PowerShell | 110311T215759Z | Joey |
| 098 | SmileBASIC | 170124T170325Z | snail_ |
| 124 | J | 170119T041809Z | Conor O& |
| 115 | Dyalog APL | 161026T135455Z | Adá |
| 182 | Ruby | 161026T050636Z | anna328p |
| 662 | JavaScript | 121120T145645Z | null |
| 019 | Clojure | 160816T130654Z | Michael |
| 281 | Emacs Lisp | 160628T162021Z | Lord Yuu |
| 121 | QR with halfblocks | 140128T213951Z | F. Hauri |
| 199 | Perl 6 | 151205T193022Z | Brad Gil |
| 139 | Python | 151120T145153Z | ig0r |
| 198 | Prolog | 151120T105405Z | Emigna |
| 264 | Hassium | 151118T151612Z | Jacob Mi |
| nan | 151118T085633Z | galdre | |
| 028 | Burlesque | 151101T184053Z | mroman |
| 6129 | Hieroglyphy With 0s | 151031T121802Z | SuperJed |
| 099 | Python | 140421T214324Z | Johannes |
| 120 | Befunge98 | 141123T030005Z | Kasran |
| 116 | Python 2 | 141123T013407Z | Kasran |
| 389 | Java | 131130T201133Z | masterX2 |
| 129 | Javascript | 140828T140631Z | vpzomtrr |
| 130 | C# | 140828T135136Z | Timwi |
| 078 | R | 140707T220958Z | shadowta |
| 049 | Ruby | 140707T215358Z | steensla |
| 279 | VBScript | 140703T212718Z | JesterBL |
| 017 | Windows Batch | 140622T104819Z | kitcar20 |
| 066 | bash | 140421T211042Z | Johannes |
| nan | 140416T200138Z | masterX2 | |
| 186 | Perl | 140413T161136Z | Heiko Ob |
| nan | 140330T130201Z | ɐɔıʇǝɥʇu | |
| 115 | Ruby | 140330T115250Z | user4740 |
| 942 | Forth | 140329T193133Z | max.hare |
| 023 | Rebol | 140211T211041Z | draegtun |
| nan | 110328T155647Z | Brad Gil | |
| 6610 | JavaScript | 140205T114521Z | sebcap26 |
| 130 | C# | 140205T004258Z | Timwi |
| 169 | C# | 140128T231939Z | microbia |
| 357 | C# | 140128T225400Z | microbia |
| 037 | Befunge 98 | 131208T010847Z | Justin |
| 102 | BrainFuck | 110311T212543Z | Kevin Br |
| nan | 131122T022820Z | Kevin Co | |
| 382 | PowerShell | 131117T061830Z | Iszi |
| 270 | Fish | 131119T164132Z | Cruncher |
| 099 | Python 3 – | 130918T232708Z | flornqua |
| nan | 130411T102741Z | Johannes | |
| 036 | Lua | 130328T112549Z | mniip |
| 016 | Python3 | 130323T085942Z | Bakuriu |
| 117 | Groovy | 130322T181948Z | Will Lp |
| 096 | Perl | 130322T140511Z | user7486 |
| 045 | Ruby | 130320T141457Z | Mikey |
| 106 | Python | 130319T014108Z | flornqua |
| nan | Java 147 | 130224T171055Z | aditsu q |
| 035 | Common Lisp | 130224T080409Z | Diego Se |
| 143 | Haskell | 110312T070428Z | MtnViewM |
| 131 | C# | 110312T210253Z | Timwi |
| 088 | JavaScript | 110311T215225Z | zzzzBov |
| 100 | JavaScript | 121120T091807Z | Pebbl |
| 190 | C | 121109T180215Z | Wug |
| 159 | Scala | 120508T094408Z | user unk |
| 128 | C | 120507T045343Z | breadbox |
| 063 | GolfScript | 120320T013905Z | Ilmari K |
| 327 | C | 120318T135835Z | ugoren |
| 272 | Python | 120318T115609Z | elssar |
| 049 | PHP – | 110313T152532Z | user344 |
| 250 | J | 110319T061840Z | Jesse Mi |
| nan | 110315T082619Z | Jagu | |
| 012 | Mathematica | 110315T063449Z | Dr. beli |
| 049 | C or C++ body segment | 110317T092337Z | Nim |
| nan | 110312T183133Z | fR0DDY | |
| 046 | Clojure | 110313T150222Z | mikera |
| 361 | Scala | 110312T220322Z | Gareth |
| 130 | Python | 110311T222705Z | Hoa Long |
| 305 | Javascript | 110312T171156Z | david4de |
| 086 | Lua | 110312T162846Z | jpjacobs |
| 435 | i386 assembly Linux | 110311T232349Z | J B |
| 146 | Haskell | 110312T090237Z | Joey Ada |
| 045 | C program | 110312T055346Z | Joey Ada |
| 201 | PHP | 110312T000208Z | Kevin Br |
| 146 | C++ | 110311T221647Z | LorenVS |
Python 3, 87 bytes
print(min(dict(Hello=0)),min(dict(World=0)),end=chr(int(-~((0**0)<<len([0,0,0,0,0])))))
Vyxal 3, 15 bytes
n½hṪṪtm½½htḢh+Ė
manipulates the alphabet builtins to create the string "kH" which is evaled to "Hello, World!"
YASEPL, 184 bytes
=O$+^^**++++++++›+++++++++++++++++++++++++++++›+++++++››+++›$+++++++++++**----›------------›*+++++++++++++++++++++++›$+******-----------------›+++›------›--------›$*****+›
char codes my beloved
Swift, 193 174 172 126 116 102 bytes
enum h{case Hello,World};print(h.Hello,"\(h.World)\(UnicodeScalar("OOOOOOOOOOO".count*"OOO".count)!)")
Ungolfed:
enum HelloWorld {
case Hello
case World
}
let exclamationPoint = String(UnicodeScalar(
String(repeating: "O", count: 11).count
* String(repeating: "O", count: 3).count
)!)
print(
HelloWorld.Hello,
String(describing: HelloWorld.World) + exclamationPoint
)
Let's go through this step by step:
enum HelloWorld {
case Hello
case World
}
When converting these cases to Strings (for example, by printing them or using them in a string interpolation), they will evaluate to "Hello" and "World", respectively.
let exclamationPoint = String(UnicodeScalar(
String(repeating: "O", count: 11).count
* String(repeating: "O", count: 3).count
)!)
Since we can't use exclamation points in identifiers, we'll have to do something else. The ASCII value of "!" is 33, so creating an 11-character String and a 3-character String and multiplying their count properties will do the job.
print(
HelloWorld.Hello,
String(describing: HelloWorld.World) + exclamationPoint
)
The print call here has 2 arguments: HelloWorld.Hello and String(describing: HelloWorld.World) + exclamationPoint, equivalent to "Hello" and "World" + "!".
By default, print separates its arguments with a space. This gives us our final result of "Hello World!". (There's actually a newline at the end because print's default terminator is a newline.)
Extra Notes
- I considered using the
-~-~-~0trick I've seen in some other answers, but Swift doesn't let you use multiple unary operators without parentheses (due to its support for custom operators), meaning it's more like-(~(-(~(-(~0))))), which is horribly inefficient.
ForWhile 22 bytes
!dlroW olleH{}+~(~~@#)
uses ForWhiles ability to read its own source code
Explanation
! invert empty stack, will push one
dlroW olleH no-ops (all letters and white spaces are interpreted as comments)
{} empty procedure, push current instruction pointer (-14)
+~ add one and flip bits (12 length of the string)
(~~@#) print the first 12 characters of the program (stored at address -1 to -12)
Python, 180 Bytes
f=lambda *a:a[0]
class Hello(metaclass=f):0
class World(metaclass=f):0
print(Hello+chr(len("OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO"))+World+chr(len("OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO")))
Explanation (might need to scroll)
f=lambda *a:a[0]
class Hello(metaclass=f):0
class World(metaclass=f):0
print(Hello+chr(len("OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO"))+World+chr(len("OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO")))
f=lambda *a:a[0] # Make a function that returns the first argument (returns the name of the class when used as a metaclass).
class Hello(metaclass=f):0 # Use the metaclass function f on the classes Hello and World to get the name of the class when called without brackets.
class World(metaclass=f):0
print(Hello+chr(len("OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO"))+World+chr(len("OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO"))) # Print "Hello World!".
chr(len("OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO")) # Space character made from unary.
chr(len("OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO")) # Exclamation mark made from unary.
💎 Created with the help of Luminespire at https://vyxal.github.io/Luminespire
(,) 375 344 334 Chars or \$334\log_{256}(3)\approx66.17\$ Bytes
(()()(),()()()()()()())((),(()()())()()())((()),(())(())(()))(((())),((()))((()))(()))(,,,(((())))()())(()(),(((())))((()))())(,,,(()()))(,,,(()())(()()()),(),,()())(,,,(()())(()))(,,,((()))(())()()()())(,,,((()))()())(,,,(((())))(())(()()()))(,,,(()())(()))(,,,(()())(())()()())(,,,(()())(()()()))(,,,(((())))((())))(,,,((()))()()())
Same as my normal answer.
Tio
Javascript, 186 Bytes
alert("O00O000OO00O0OOO0OO00OO0OO00OO0OOOO0O00000O0O0OOOOO0OOOOOOO00O0OO0OO00OO00O00".replace(/\D/g,-~0).replace(/......./g,function(O){return String.fromCharCode(parseInt(0+O,-~!0));}))
Arturo, 34 bytes
prints['Hello]prints'World print'!
Using literals (what might be called symbols in most languages) and a symbolLiteral for the !. Luckily they can be printed directly. A minimum of 3 prints must be used to force the correct spacing.
Julia 1.0, 45 bytes
print(string(:([Hello World!]))[-~-~0:~-end])
This is not cheating (I think)
:(...)is anExpr, which represents Julia code (AST or something)[Hello World!]is a 2 by 1 Matrix containing two variablesHelloandWorld!. They don't need to be defined since they are in anExpr(internally stored as Symbols)stringturns theExprinto a string:"[Hello World!]"- we remove the brackets:
-~-~0is2and~-endisend-1
Pascal (FPC), 1245 bytes
it's kinda long and crazy ngl
{$macro on}
{$define _O:=chr(Length(}
{$define O_:=))}
begin
write(_O'000000000000000000000000000000000000000000000000000000000000000000000000'O_,_O'00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'O_,_O'000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'O_,_O'000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'O_,_O'000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'O_,_O'00000000000000000000000000000000'O_,_O'000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'O_,_O'000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'O_,_O'000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'O_,_O'000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'O_,_O'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'O_,_O'000000000000000000000000000000000'O_);
end.
Microsoft Excel, 178 131 chars
Uses the following cells:
A1-=0=0TRUE. Since we don't need a real "1", we can just abuse coercion.A2-=A1+A1TRUE + TRUE = 2A3-=A2+A12 + TRUE = 3A4-=A3+A13 + TRUE = 4A6-=A4+A24 + 2 = 6A8-=A6+A26 + 2 = 8A9-=A8+A18 + TRUE = 9B8-=A4&A242B9-=A3&A333B1-=PROPER(BASE(A8&0&A2&A9&B8&A2,A2&A6)&" "&BASE(A3&A8&A8&B8&0&A6&A9,B9)&CHAR(B9))"Hello World!"
5 + 6 * 8 + 79 = 131 chars.
Only a 0 literal was used. Every other value is a reference dependent on that.
Unobfuscated, the formula is
=PROPER(BASE(8029422,26)&" "&BASE(38842069,33)&CHAR(33))
APL (Dyalog Unicode), 35 bytesSBCS
{⍞←⍺,⍵,⍨⊃⍕⍬⋄⍞←!}/⎕NL≡Hello World←⍬0
⍬0 the list [[];0]
Hello World← store those two values in these two variables
≡ the depth of that array; ¯2 (max-depth is 2, negative means ragged)
⎕NL Name List of defined variables (class 2 — negative means return as list of strings)
{…}/ apply the following anonymous lambda infix between the two names:
⍬ empty list; []
⍕ stringify; ""
⊃ coerce the first character; " "
⍵,⍨ append the right argument; " World"
⍺, prepend the left argument; "Hello World"
⍞← print that to stdout with no trailing line break
⋄ then:
⍞←! print the factorial function to stdout
Runic Enchantments, 94 bytes
mmXm-m-FFm-k$Xm+mm,+:m-:k$Fm+k::}$$::,:++k:}$mKymmmm+++k$mmqnmm,-k${${:FFm+k$k$Fmm+Xk$FFmmqnk@
Wouldn't surprise me if there's a shortcut or two I missed to construct the required values in fewer bytes (mmmm+++ is particularly gross), but managing the stack with duplicated values to be used later incurs its own overhead (as does adjusting the IP
s mana value). As such only the o and l in World are utilized this way, as they are constructed in the order lo and required again later in the order ol, so only 6 total bytes are needed to dup and rotate.
The program functions by drawing on the inherent mana of the instruction pointer to generate numerical values, then performing arithmetic operations on that value as necessary to generate the decimal values 72, 101, 108, 111, 32, 87, 114, 100 in order, casting each to char and printing them.
m -> push current mana value to stack (default 10)
F -> lower mana value by 1 ("Fizzle")
mK -> increase mana value by 1 (spawns an IP with m mana, costs m-1, then they combine)
X -> multiply top of stack by 10 (note that this is not a literal value)
k -> cast top of stack to Char
$ -> print top of stack
In this way the sequence mXm-m- gives the value 80. FFm gives the value 8. 80 - 8 = 72:
mXm-m-FFm-k$ causes H to be printed.
JavaScript, 166 bytes
(o=-~0,O=o+[],e=O+0,c=e+0,q=O+c,d=c+0,p=e+O+O+O)=>[c+d,q+e+O,a=O+e+q,a,g=O+p+O,d+0+0,e+p,g,O+q+e,a,q+c,d+0+O].map(b=>String.fromCharCode(parseInt(b,o+o))).join([]+[])
I tried to use most circular alphabet as possible for the variable names.
Keg, 14 bytes
Hello World*
- Keg does not have character literals, only instructions that push constants onto the stack, except for
\, which pushes the character onto the stack. - This program does not use integers.
- There are no built-functions that return the string in Keg.
- Keg does not support regex.
Forth (gforth), 38 bytes
: f name type ; f Hello space f World!
OR
name World! name Hello type space type
Explanation
Uses the Forth built-in for processing code to convert the next character entered to a string, and then prints it
Code Explanation
: f \ start a new word definition
name \ grabs the next word (space-delimited) from the input/code
type \ output the string on top of the stack
; \ end word definition
f Hello \ converts and outputs Hello, as name will grab Hello from the input before continuing
space \ outputs a single space
f World! \ converts World! to a string and outputs it
F#, 103 bytes
let[<EntryPoint>]``Hello world!``a=System.Reflection.MethodBase.GetCurrentMethod().Name|>stdout.Write;0
Similar to some of the other answers here. The `` characters around the method name are not literals, rather they "delimit an identifier that would otherwise not be a legal identifier, such as a language keyword." (Source)
They do make F# nice for writing tests, since you can give a long human-language name for the tests instead of a programming-language name.
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.
Tcl, 62 bytes
proc Hello\ world! {} {puts {*}[info level 0]}
[Hello\ world!]
proc Hello\ World! is a function with name "Hello world"; [info level 0] gives the funtion name where I am presently now; [Hello\ world!] is a call to the "Hello world" function!
Lenguage, 12731474882444739483739382239546264946233453512894971245352595483589354073858968246926319892 bytes
It is 12731474882444739483739382239546264946233453512894971245352595483589354073858968246926319892 zeros. Or Os. Both of them if you want. Any character in fact. Thanks Lenguage.
Convert It Online! <-- Conversion from brainfuck Hello World!
Try It Online! <-- brainfuck Hello World! in action
Unlambda, 37 bytes
Note that Unlambda doesn't have string or integer literals; .a is a function with a two-character name that writes a to standard output; it's not a function . that takes a as argument.
`.!`.d`.l`.r`.o`.W`. `.o`.l`.l`.e`.Hi
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:
+++++++++++++++++++++++++++++++++++++++++++++
+++++++++++++++++++++++++++.+++++++++++++++++
++++++++++++.+++++++..+++.-------------------
---------------------------------------------
---------------.+++++++++++++++++++++++++++++
++++++++++++++++++++++++++.++++++++++++++++++
++++++.+++.------.--------.------------------
---------------------------------------------
----.-----------------------.
C, 177 bytes
enum{a,b,c=b+b,d=c*c,e=c*d,f=c*e,g=c*f,h=c*g,i=c*h};x[]={h+e,i-g+d+b,i-g+e+d,i-g+e+d,i-g+f-b,g,h+f+e-b,i-g+f-b,i-f+c,i-g+e+d,i-g+d,g+b,},j=a;main(){for(;j<f-d;putchar(x[j++]));}
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);}
JavaScript (ES5), 79 bytes
b=-~!0;for(c in{Hello:a="",World:b<<=b*b})a+=c+String.fromCharCode(b++);alert(a)
Explanation
Like the other JavaScript answers, this is just a code snippet that alerts the string'Hello World!'.
The first trick is creating an object with the key names Hello and World. These are not string literals, so it obeys the rules. It is not allowed to put the exclamation mark or the space in there, so we get those characters through the second trick.
The second trick is getting the characters through their ASCII value. Sadly, we have to use String.fromCharCode for that, which is really long. Luckily, the space (32) and exclamation mark (33) are right next to each other in the ASCII table, and the character code for the space is a nice power of 2, which is easily obtainable though bitshifting. Getting 32 using only zeroes is a little bit tricky: 32 equals 1 << 5, which is not very golfable, but it also equals 2 << 4 = 2 << 2 * 2. All these two's allow us to assign 2 to a variable, and use that (note that -~!0 equals 2).
The third trick is that we don't need the values in the object we loop over, and you can assign values to variables in the object declaration. This doesn't just save 2 semicolons, but also 2 dummy values, so 4 bytes in total.
JavaScript (ES6) (non-competing), 82 bytes
_=>eval('b=-~!0;for(c in{Hello:a="",World:b<<=b*b})a+=c+String.fromCharCode(b++)')
Explanation
This is a full function with the same body as the competing version, but we use a fat-arrow function with "the eval trick". eval returns the value of the last variable it assigned to, which is a in this case.
This is non-competing since ECMAScript 6 was released in 2015, more than 4 years after this challenge was made.
PHP, 160 157 bytes
no literals at all. Still wonder if it has golfing potential left:
for(;$c=[$h=($f=($t=++$n+$n)+$t)+$f+$s=$f*$f*$f,$e=$s+$s/$t+$v=$f+$n--,$l=$e+$f+--$f,$l,$o=$l+$f,$s/=$t,$h+$v*$f,$o,$o+$f,$l,--$e,++$s][+$i++];)echo chr($c);
creates an array with the ascii codes and loops through it to print the characters.
Run with -nr or try it online.
breakdown
for(;$c=[$h=
($f=($t=++$n+$n)+$t) # $n=1,$t=2,$f=4
+$f+$s=$f*$f*$f, # H $s=64,$h=72
$e=$s+$s/$t+$v=$f+$n--, # e $n=0,$v=5,$e=101
$l=$e+$f+--$f,$l, # ll $f=3,$l=108
$o=$l+$f, # o $o=111
$s/=$t, # space $s=32
$h+$v*$f,$o, # Wo
$o+$f,$l, # rl
--$e, # d $e=100
++$s # ! $s=33
][+$i++];) # loop through array
echo chr($c); # print character
ZX Spectrum BASIC, 16 bytes
(including the end of line, but excluding the line number, since that is not part of the code itself)
The hexadecimal representation of the code is:
08 08 48 65 6c 6c 6f 2c 20 77 6f 72 6c 64 21 0d
Its "normal" entry would be:
1\x08\x08Hello, world!
where 1 is the (unimportant) line number, \x08 means byte with the value 0x08 - you might have to overcome some slight difficulties if you want to enter it from the keyboard.
Note that Hello, world! is not a string literal, but part of the code itself.
Bonus: you do not have to RUN the program, just "having" it in the computer is enough (in keyword mode) to display:
If you accept "garbage" around the message, the code could be made shorter by three bytes.
PHP, 136 bytes
a different approach, inspired by Adám´s APL answer:
for(;$c=[O00O000,OO00O0O,$l=OO0OO00,$l,$o=OO0OOOO,O00000,O0O0OOO,$o,OOO00O0,$l,OO00O00,O0000O][+$i++];)echo chr(bindec(strtr($c,O,!0)));
loops through array of 0O encoded ASCII values to print corresponding characters. Run with -nr.
breakdown
for(;$c=[O00O000,OO00O0O,$l=OO0OO00,$l,$o=OO0OOOO, // binary ascii codes,
O00000,O0O0OOO,$o,OOO00O0,$l,OO00O00,O0000O] // 1 replaced with O
[+$i++];) // loop through array
echo // 4. print
chr( // 3. convert to character
bindec( // 2. convert to decimal
strtr($c,O,!0) // 1. replace capital O with 1
));
Commodore 64 O.0! interpreter
The best I could come up with was to write an interpreter that would accept O and 0 - O starts the counter from 65 (A) and 0 adds 1 to the counter, so you have to enter the following to produce HELLOWORLD**
O0000000O0000O00000000000O00000000000O00000000000000O0000000000000000000000O00000000000000O00000000000000000O00000000000O000
Which I work out at 124 characters. To use, run the program and start typing with O, enter 0 to increase the character count and begin a new character with O again.
** The current version of the interpreter does not support the space or new line character, and you have to break [RUN/STOP] to stop it
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.
SmileBASIC, 98 bytes (non-competing)
I admit, this answer is cheating. Labels transparently behave as strings when in an expression, but technically they aren't string or character literals, right? If anyone wants to weigh in feel free but I'm convinced a SmileBASIC answer would just amount to abusing PI() or EXP() to compute every character code.
S=VAL(RIGHT$(@32,2))?RIGHT$(@Hello,5)+CHR$(S+LEN(@O0O0O0O0O0O))+CHR$(S)+RIGHT$(@world,5)+CHR$(S+1)
You could easily golf this more, I'm sure.
J, 134 124 bytes
Thanks to miles for a bugfix!
echo u:#.((+:+:>.^#a:),<.^+:*_)$'0O'i.'O00O000OO00O0OOO0OO00OO0OO00OO0OOOO0O00000O0O0OOOOO0OOOOOOO00O0OO0OO00OO00O000O0000O'
Try it online! This was much easier to write than the below.
Alternatively, no strings, 134 bytes:
echo u:(-:*:>.>:C),(>:*:<.C),A,A,B,(+:+:>.C),(+:*:<.^.A),(<.*:+:^.A),(B=:>:>:>:A),(+:>:>:>:-:A),A,(*:<.C=:%:A),>.*:>:^.A=:+:<.^+:+:#a:
Try it online! This. Was. A. Triumph Pain to write. I should really write a program to help me automate this...
Dyalog APL, 115 bytes
Needs ⎕IO←0 which is default on many systems.
Plain ASCII encoding using 0 for 0 and O for 1.
⎕UCS(⍴⍬⍬)⊥'0O'⍳'OOOOO0OOOOO00OOOOO0OOOOO000000O0O000O0OOO00O0O000OOOO0OO0OO00000O0OOO0000O00O0OO000O'⍴⍨≢¨⎕TS(⎕D,⍬⍬)
⎕UCS Convert Unicode code points to character
(⍴⍬⍬)⊥ base-2 decode of (⍴⍬⍬ is the length of a list of two empty lists, i.e. 2)
'0O'⍳ indices into 0O for each character in
'OOO...00O' the 7×12 character encoded string
⍴⍨ reshaped into a matrix of dimensions
≢¨ the tally of each of
⎕TS(⎕D,⍬⍬) the Time Stamp and the Digits appended with two empty lists
Ruby, 182 bytes
->{o=?O.ord;o/=o;t=o+o;"O00O000OO00O0OOO0OO00OO0OO00OO0OOOO0O00000O0O0OOOOO0OOOOOOO00O0OO0OO00OO00O000O0000O".tr(?O,o.to_s).chars.each_slice(t+t+t+o).map{|i|i.join.to_i(t).chr}.join}
Lambda function, returns desired value.
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.
Clojure, 19 bytes
Since I am not allowed to comment (yet) both of atrociously long Clojure answers, here is mine:
(pr 'Hello 'World!)
3 bytes shorter than print
Emacs Lisp, 281 bytes
(defalias'O'string-to-char)
(setq O(1+(O"O"))O0(-(1+ O)(O"O"))OO(* O0 O0 O0 O0 O0 O0)O1(+ O(- O OO))OOO(+ O1 (* O0 O0 O0) O0 O0)OO1(1+ (+ OOO O0)))
(princ(string(-O(* O0 O0 O0))(1+(+ O1 O0 O0))OOO OOO OO1 (/ OO O0)(1+ (+ O O0 O0 O0))OO1(1+ (+ OO1 O0))OOO(+ O1 O0 O0)(1+(/ OO O0))))
1+ is not a number, but a function, that returns 1 + NUMBER with NUMBER as its argument.
Ungolfed:
(defalias'O'string-to-char)
(setq O (1+ (O"O")) ; 80 => "P"
O0 (-(1+ O)(O"O")) ; 2
OO (* O0 O0 O0 O0 O0 O0) ; 64
O1 (+ O(- O OO)) ; 96
OOO (+ O1 (* O0 O0 O0) O0 O0) ; 108 => "l"
OO1 (1+ (+ OOO O0))) ; 111 => "o"
(princ
(string
(- O (* O0 O0 O0)) ; "H"
(1+(+ O1 O0 O0)) ; "e"
OOO ; "l"
OOO ; "l"
OO1 ; "o"
(/ OO O0) ; " "
(1+ (+ O O0 O0 O0)) ; "W"
OO1 ; "o"
(1+ (+ OO1 O0)) ; "r"
OOO ; "l"
(+ O1 O0 O0) ; "d"
(1+ (/ OO O0)))) ; "!"
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:

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**@_})
Python, 139 bytes
class World():
pass
class Hello(World):
def __init__(self):
print(self.__class__.__name__, self.__class__.__base__.__name__)
O=Hello()
Prolog, 198 bytes
p:-atom_codes('O0',[O,N]),A is O-N,B is O/O,C is A-B-B,D is B+B+B,G is O+C,H is G+D,I is H+D,K is A+B,L is K+B,M is C*D,J is L*D+B,F is J+B,E is F-C,atom_codes(X,[E,F,G,G,H,K,M,H,I,G,J,L]),write(X).
Explanation
p:-atom_codes('O0',[O,N]), % O=79, N=48
A is O-N, % A=79-48=31
B is O/O, % B=79/79=1
C is A-B-B, % C=31-1-1=29
D is B+B+B, % D=1+1+1=3
G is O+C, % G=79+29=108
H is G+D, % H=108+3=111
I is H+D, % I=111+3=114
K is A+B, % K=31+1=32
L is K+B, % L=32+1=33
M is C*D, % M=29*3=87
J is L*D+B, % J=33*3+1=100
F is J+B, % F=100+1=101
E is F-C, % E=101-29=72
atom_codes(X,[E,F,G,G,H,K,M,H,I,G,J,L]), % X='Hello World!'
write(X).
Hassium, 264 Bytes
Well this was interesting.
use Math;func main(){a=Math.pi;a/=a;b=a+a;t=Math.pow(b+b,b+a);o=t+Math.pow(b*b+b,b);d(t+(b*b*b));d(o+a);c=o+(b*b*b)d(c)d(c)d(c+b+a)d(Math.pow(b*b,b)*2)d(o-((b*(b*b)+(b*b+a))))d(c+b+a)d((c+b+a)+(b+a))d(c)d(o)d(Math.pow(b*b,b)*b+a);}func d(m)print(Convert.toChar(m))
Run online and see expanded here
Clojure
The stupid simple (22):
(print 'Hello 'World!)
These are technically symbols, not strings.
In the spirit of the puzzle (204):
(apply str(map(comp char(fn f[x](if x(+(#(+ % %)(f(next x)))({\O (inc 0) \0 0} (first x)))0)) reverse str)'[O00O000 OO00O0O OO0OO00 OO0OO00 OO0OOOO O00000 O0O0OOO OO0OOOO OOO00O0 OO0OO00 OO00O00 O0000O]))
Burlesque, 28 bytes
blsq ) {Hello,}m]\[{world!}m]\[ClwD
Hello, world!
Explanation:
{Hello,} is actually a Block containing the commands He, ll and o,.
The reason we can't use {Hello, world!} is because the parser skips whitespaces obviously. m] converts commands to strings and \[ concatenates them. With wD (which is unwords) we insert missing space.
For what it's worth a few notes about how Burlesque parses commands.
Pretty much everything that does not start with a digit will be parsed as a command with the exception of the minus sign which tries to parse a double first, if that fails it tries to parse it as an integer and if that fails it tries to parse it as a command. For example a{b} contains NO block. That's the command a{ followed by the command b}. {ab} is a block that contains the command ab. {-}-}} is a block containing the command -} twice. a2.0 is the command a2 followed by the command .0. (That 2.0 is NOT a double in there).
Hieroglyphy With 0s, 6129
Golfed down from a generated expression in pure hieroglyphy (itself a variant of the infamous JSF***) which was 7999 bytes long.
Basically exploits the oddities of javascript's type system to generate the string using only the character set [](){}+!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]+([]+{})[!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+!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]+(!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]+(!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]+(![]+[])[!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+!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]+([]+{})[!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+!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]][([]+{})[!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+[])[+!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+!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+!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+!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]+([]+{})[!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+!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]+(!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]+(!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]+(![]+[])[!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+!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]+([]+{})[!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+!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]][([]+{})[!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+[])[+!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+!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+!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+[])[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]+(!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]+[])[+!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+!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]+[])[!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]+(+{}+[])[+!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+[])[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]+(!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+!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]+(![]+[])[!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+[])[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]+[])[!0+!0+!0+!0+!0]+([]+{})[+!0]+([][0]+[])[+!0])())[!0+!0+!0]+([][0]+[])[!0+!0+!0])()(([]+{})[0])[0]+(!0+!0+[])+(+!0+[]))
Because this "language" is a subset of javascript, you can run this right from your browser console. It returns the string "Hello World!".
Python (99 bytes)
o=-~0
def World():0
def Hello():print Hello.__name__,World.__name__+chr(o+(o<<(o+o+o+o+o)))
Hello()
(similar to my bash version ).
EDIT: Cut another byte by optimising 0**0 to -~0 (== 1), thanks to @kasran for the tip!
Befunge-98, 120
'O0!::+::+*-++:,0!::+::*:**\::++-++:,0!::+::+*--+:,+:,0!::++++:,'O%+:,\#@_0!\0!::++/0!:++:0\-0!+:0!:+/:0!:++:0!-::0!:++*
One long line of Befunge. Yikes.
This basically just prints "Hello ", loads in a list of offsets, and then runs the Hello-printing bit again with some offsets applied to turn "Hello " into "World!". It can probably be golfed down a bit further with the representations of numbers.
Edit - Removed two extraneous spaces that had snuck in.
Python 2, 116
def Hello(n,m,j):print n.func_name,m.func_name+chr(j)
def World():pass
o=-~0;O=o+o;P=O<<O*O;Hello(Hello,World,P+o)
This is the best I can do so far. Hooray, func_name! (I may or may not try this in Befunge as well.)
(Oops, someone already did this better. Upvote that one instead.)
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
}
Javascript - 129 chars
s=[,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,];c=String.fromCharCode;alert(Object.keys({Hello:s,World:s}).join(c(s.length))+c(++s.length));
C# (130 chars)
class 聇聤聫聫聮耟聖聮聱聫聣耠{static void Main(){foreach(var c in typeof(聇聤聫聫聮耟聖聮聱聫聣耠).Name)System.Console.Write((char)(c-short.MaxValue));}}
Even though this beats my 131 chars solution, posting this as a separate answer because it works very differently and the other one is more interesting. (And also because the other one is ASCII-only and thus only 131 bytes long.)
R, 78
paste(deparse(quote(Hello)),paste0(deparse(quote(World)),deparse(quote(`!`))))
Wanton abuse of deparse (which extracts the literal name of an object, i.e. "de-parsing" it, even if that object doesn't exist) and R's name class, which is not a string literal; is.character(quote(Hello)) returns FALSE. Also ! is a function in R, hence the backticks.
But for a (slightly) more honest solution,
R, 391 after removing whitespace
u = !is.na("O")
paste(
paste0(letters[u+u+u+u+u+u+u+u],
letters[u+u+u+u+u],
letters[u+u+u+u+u+u+u+u+u+u+u+u],
letters[u+u+u+u+u+u+u+u+u+u+u+u],
letters[u+u+u+u+u+u+u+u+u+u+u+u+u+u+u]),
paste0(letters[u+u+u+u+u+u+u+u+u+u+u+u+u+u+u+u+u+u+u+u+u+u+u],
letters[u+u+u+u+u+u+u+u+u+u+u+u+u+u+u],
letters[u+u+u+u+u+u+u+u+u+u+u+u+u+u+u+u+u+u],
letters[u+u+u+u+u+u+u+u+u+u+u+u],
letters[u+u+u+u])
)
In R, there is a built-in object called letters that's, well, a vector of letters. is.na returns FALSE because "O" is not equal to the special value NA, and ! negates the logical (aka Boolean). Then + in R automatically coerces logicals to numerics.
Ruby 49 chars
def Hello World!;puts __method__;end
Hello World!
The whitespace in the method name is a UTF8 Emsp, a little wider then a normal space which would be a syntax error.
VBScript: 279
o = Asc("O")
n = 0 ^ 0
w = Round(Cos(o) / Sin(o), 0)
r = Cos(0) + Sgn(o) + Exp(0)
u = Fix(Log(o))
v = Left(o, o ^ 0)
e = Int(Sqr(o))
MsgBox Join(Array( _
Chr(v & w), _
Chr(n & 0 & n), _
Chr(n & 0 & e), _
Chr(n & 0 & e), _
LCase("O"), _
Chr(u & u), _
Chr(r & w), _
Chr(e & v), _
Chr(n & n & n), _
Chr(n & n & u), _
Chr(n & 0 & e), _
Chr(n & 0 & 0), _
Chr(r & r) _
), String(0, "O"))
Strategy
Generate the numbers 1,2,3,4,7, and 8 from "O" and 0 and common functions
Concatenate the numbers together as strings to form ascii values
Put ascii values in an array
Join the array into a string using an empty string (repeat "o" 0 times) as the delimiter
Display!
This golfs down to (a very beatable) 279 by removing underscores, linebreaks, and all spaces except for one to seperate 'msgbox' and 'join' and more to keep &0s from behaving like hex literals
o=Asc("O"):n=0^0:w=Round(Cos(o)/Sin(o),0):r=Cos(0)+Sgn(o)+Exp(0):u=Fix(Log(o)):v=Left(o,o^0):e=Int(Sqr(o)):MsgBox Join(Array(Chr(v&w),Chr(n& 0&n),Chr(n& 0&e),Chr(n& 0&e),LCase("O"),Chr(u&u),Chr(r&w),Chr(e&v),Chr(n&n&n),Chr(n&n&u),Chr(n& 0&e),Chr(n& 0& 0),Chr(r&r)),String(0,"O"))
bash, 66 characters
66 characters, no new lines
Hello(){ H=$FUNCNAME;};World! (){ echo $H $FUNCNAME;};Hello;World!
Previous version (81 characters), left here because I like the $IFS trick :-)
81 characters, no new lines
Hello(){ H=$FUNCNAME;};World! (){ echo $H${IFS:0:$[0**0]}$FUNCNAME;};Hello;World!
81 as well but with (including) new lines and easier to read
Hello(){ H=$FUNCNAME;}
World! (){ echo $H${IFS:0:$[0**0]}$FUNCNAME;}
Hello;World!
Commented version
Hello(){ H=$FUNCNAME;} # set $H to function name ("Hello")
World! (){ echo $H${IFS:0:$[0**0]}$FUNCNAME;} # print $H, first char of $IFS (" ") & "World!"
Hello;World! # run the stuff
(strictly speaking the calculation 0**0 should be indeterminate but it evaluates to 1 :-D)
Java @230 : Twisting the rules with Enumerator behavior
enum A{Hello,B,C,D,E,F,World;public static void main(String[]z){p(Hello);int b=(B.ordinal()),c=(b<<F.ordinal());p((char)(c|b<<D.ordinal()|b<<(b<<b)));p((char)c++);p(World);p((char)c);}static void p(Object o){System.out.print(o);}}
took me a while to figure the logic out, enums printed act like literals and cn donate numbers at the same time :P
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
Python:
print str().join([chr((~0*(~0+~0))**(~0*(~0+~0+~0))*(~0*(~0+~0+~0))**(~0*(~0+~(0)))),
chr((~0*(~0+~0))**(~0*(~0+~0))*(~0*(~0+~0+~0+~0+~0))**(~0*(~0+~0))+~0*~0),
chr((~0*(~0+~0))**(~0*(~0+~0))*(~0*(~0+~0+~0)**(~0*(~0+~0+~0)))),
chr((~0*(~0+~0))**(~0*(~0+~0))*(~0*(~0+~0+~0)**(~0*(~0+~0+~0)))),
chr((~0*(~0+~0))**(~0*(~0+~0+~0+~0))*~0*(~0+~0+~0+~0+~0+~0+~0)+~0),
chr((~0*(~0+~0))**(~0*(~0+~0+~0+~0+~0))),
chr((~0*(~0+~0))**(~0*(~0+~0+~0))*(~0*(~0+~0+~0))*(~0*(~0+~0+~0+~0+~0))+~0),
chr((~0*(~0+~0))**(~0*(~0+~0+~0+~0))*~0*(~0+~0+~0+~0+~0+~0+~0)+~0),
chr((~0*(~0+~0))**(~0*(~0+~0))*(~0*(~0+~0+~0+~0+~0))**(~0*(~0+~0))+(~0*(~0+~0))**((~0+~0)*(~0+~0))+~0+~0),
chr((~0*(~0+~0))**(~0*(~0+~0))*(~0*(~0+~0+~0)**(~0*(~0+~0+~0)))),
chr((~0*(~0+~0))**(~0*(~0+~0))*(~0*(~0+~0+~0+~0+~0))**(~0*(~0+~0))),
chr((~0*(~0+~0))**(~0*(~0+~0+~0+~0+~0))+~0*~0)
])
Ruby, 115 characters
No numbers or string literals whatsoever.
[(s=-(x=(z=[z].size)+y=z+z)+q=x*x+z)*q+y,z+f=q*q,l=f+q-y,l,o=l+x,_=q*x+y,(s+z)*q+s,o,o+x,l,f,_+z].map{|x|$><<x.chr}
Ruby, 110 characters (but less awesome)
This one has a zero. :(
[(s=-(x=(z=-~0)+y=z+z)+q=x*x+z)*q+y,z+f=q*q,l=f+q-y,l,o=l+x,_=q*x+y,(s+z)*q+s,o,o+x,l,f,_+z].map{|x|$><<x.chr}
Forth (942)
I'm sure it's not the shortes forth solution... but it's binary! First 5 lines are driver.
: O0 0 ;
: OO 0 0 INVERT - ;
: 00 SWAP 2 * + ;
: OOOOOOOO EMIT ;
: O CR BYE ;
O0 OO 00 O0 00 O0 00 OO 00 O0 00 O0 00 O0 00 OOOOOOOO
O0 OO 00 OO 00 O0 00 O0 00 OO 00 O0 00 OO 00 OOOOOOOO
O0 OO 00 OO 00 O0 00 OO 00 OO 00 O0 00 O0 00 OOOOOOOO
O0 OO 00 OO 00 O0 00 OO 00 OO 00 O0 00 O0 00 OOOOOOOO
O0 OO 00 OO 00 O0 00 OO 00 OO 00 OO 00 OO 00 OOOOOOOO
O0 O0 00 OO 00 O0 00 O0 00 O0 00 O0 00 O0 00 OOOOOOOO
O0 OO 00 O0 00 OO 00 O0 00 OO 00 OO 00 OO 00 OOOOOOOO
O0 OO 00 OO 00 O0 00 OO 00 OO 00 OO 00 OO 00 OOOOOOOO
O0 OO 00 OO 00 OO 00 O0 00 O0 00 OO 00 O0 00 OOOOOOOO
O0 OO 00 OO 00 O0 00 OO 00 OO 00 O0 00 O0 00 OOOOOOOO
O0 OO 00 OO 00 O0 00 O0 00 OO 00 O0 00 O0 00 OOOOOOOO
O0 O0 00 OO 00 O0 00 O0 00 O0 00 O0 00 OO 00 OOOOOOOO
O
Edit #1: I'm stupid! I had to insert 2 noop instructions to make it look nearly like a real dump of /dev/zero...
: O0 0 ;
: OO 0 0 INVERT - ;
: 00 SWAP 2 * + ;
: OOOOOOOO EMIT ;
: 00000000 ;
: 0O ;
: O CR BYE ;
O0 OO 00 O0 00 O0 00 OO 00000000
00 O0 00 O0 00 O0 00 0O OOOOOOOO
O0 OO 00 OO 00 O0 00 O0 00000000
00 OO 00 O0 00 OO 00 0O OOOOOOOO
O0 OO 00 OO 00 O0 00 OO 00000000
00 OO 00 O0 00 O0 00 0O OOOOOOOO
O0 OO 00 OO 00 O0 00 OO 00000000
00 OO 00 O0 00 O0 00 0O OOOOOOOO
O0 OO 00 OO 00 O0 00 OO 00000000
00 OO 00 OO 00 OO 00 0O OOOOOOOO
O0 O0 00 OO 00 O0 00 O0 00000000
00 O0 00 O0 00 O0 00 0O OOOOOOOO
O0 OO 00 O0 00 OO 00 O0 00000000
00 OO 00 OO 00 OO 00 0O OOOOOOOO
O0 OO 00 OO 00 O0 00 OO 00000000
00 OO 00 OO 00 OO 00 0O OOOOOOOO
O0 OO 00 OO 00 OO 00 O0 00000000
00 O0 00 OO 00 O0 00 0O OOOOOOOO
O0 OO 00 OO 00 O0 00 OO 00000000
00 OO 00 O0 00 O0 00 0O OOOOOOOO
O0 OO 00 OO 00 O0 00 O0 00000000
00 OO 00 O0 00 O0 00 0O OOOOOOOO
O0 O0 00 OO 00 O0 00 O0 00000000
00 O0 00 O0 00 OO 00 0O OOOOOOOO
O
Rebol (23 chars)
print ['Hello 'World!]
NB. In Rebol these are word literals ('word) which are completely different to string literals ("string"):
>> type? 'Hello
== word!
>> type? "Hello"
== string!
Alternative if you think using word literals is cheating!
print [quote Hello quote World!]
Heres my Perl entry.
It uses the length of an array to store the ordinal of the character.
use strict;
use warnings;
use 5.010;
my @hello_world = (
[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,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,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,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,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,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,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,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,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,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,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,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,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,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,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,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,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,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,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,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,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,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,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,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,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,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,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,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,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,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,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,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,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,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,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,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,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,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,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,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,0,0,0,0,0,0,0,0,0,0,0,0],
);
say map{ chr @$_ } @hello_world;
That seemed like a lot of writing to me, so I used this to generate the above code:
perl -E'
say for map{"use $_;"} qw"strict warnings 5.010";
say "my \@hello_world = (";
say " [",join(",",@$_),"]," for map{[(0) x ord]} split //, "Hello World";
say ");";
say q"say map{ chr @$_ } @hello_world;"
'
JavaScript, 661 characters (without "O" or 0)
That's not the shortest, but that was funny to make. I tried to make it without 0 or "O".
I'm not really happy with H and W because it's the only ones which uses non-symbols characters, but that works. If anyone has an idea to do it ...
This is javascript code, tested in firefox 27 scratchpad, and running with Ctrl+I (should I add an alert or console.log ?).
(document+[])[(++[[]+[]][+[]])<<(++[[]+[]][+[]])<<(++[[]+[]][+[]])<<(++[[]+[]][+[]])] // H
+((!!{})+[])[((++[[]+[]][+[]])<<(++[[]+[]][+[]]))+(++[[]+[]][+[]])] // e
+([]+(![]))[(++[[]+[]][+[]])<<(++[[]+[]][+[]])] // l
+([]+(![]))[(++[[]+[]][+[]])<<(++[[]+[]][+[]])] // l
+([]+{})[++[[]+[]][+[]]] // o
+([]+{})[((++[[]+[]][+[]]<<(~!+[]))+[])[(++[[]+[]][+[]])<<(++[[]+[]][+[]])]] //
+(self+[])[(++[[]+[]][+[]])<<(++[[]+[]][+[]])<<(++[[]+[]][+[]])<<(++[[]+[]][+[]])] // W
+([]+{})[++[[]+[]][+[]]] // o
+([]+(!!{}))[++[[]+[]][+[]]] // r
+([]+(![]))[(++[[]+[]][+[]])<<(++[[]+[]][+[]])] // l
+([][+[]]+[])[(++[[]+[]][+[]])<<(++[[]+[]][+[]])<<(++[[]+[]][+[]])<<(++[[]+[]][+[]])] // d
+((/!/)+[])[++[[]+[]][+[]]] // !
(the count of 661 of course doesn't include the comments)
C#, 130 characters
A friend of mine came up with this solution, which is one character shorter than my own solution of 131 (but longer if you count bytes).
class 聇聤聫聫聮耟聖聮聱聫聣耠{static void Main(){foreach(var c in typeof(聇聤聫聫聮耟聖聮聱聫聣耠).Name)System.Console.Write((char)(c-short.MaxValue));}}
Readable:
class 聇聤聫聫聮耟聖聮聱聫聣耠
{
static void Main()
{
foreach (var c in typeof(聇聤聫聫聮耟聖聮聱聫聣耠).Name)
System.Console.Write((char)(c - short.MaxValue));
}
}
C# (169)
class HelloOWorld0
{
public static void Main()
{
Console.WriteLine(typeof(HelloOWorld0).Name.Replace('O', (char) ConsoleKey.Spacebar).Replace('0', (char) ConsoleKey.PageUp));
}
}
Minified:
class HelloOWorld0{public static void Main(){Console.WriteLine(typeof(HelloOWorld0).Name.Replace('O',(char)ConsoleKey.Spacebar).Replace('0',(char) ConsoleKey.PageUp));}}
C# (357)
class H
{
static void main()
{
Func<ConsoleKey, char> f = (k) => (char) k;
Func<char, char> l = (c) => char.ToLower(c);
Console.WriteLine(new[] {
f(ConsoleKey.H),
l(f(ConsoleKey.E)),
l(f(ConsoleKey.L)),
l(f(ConsoleKey.L)),
l(f(ConsoleKey.O)),
f(ConsoleKey.Spacebar),
f(ConsoleKey.W),
l(f(ConsoleKey.O)),
l(f(ConsoleKey.R)),
l(f(ConsoleKey.L)),
l(f(ConsoleKey.D)),
f(ConsoleKey.PageUp)
});
}
}
Golfed:
class H{static void main(){Func<ConsoleKey,char>f=(k)=>(char)k;Func<char,char>l=(c)=>char.ToLower(c);Console.WriteLine(new[]{f(ConsoleKey.H),l(f(ConsoleKey.E)),l(f(ConsoleKey.L)),l(f(ConsoleKey.L)),l(f(ConsoleKey.O)),f(ConsoleKey.Spacebar),f(ConsoleKey.W),l(f(ConsoleKey.O)),l(f(ConsoleKey.R)),l(f(ConsoleKey.L)),l(f(ConsoleKey.D)),f(ConsoleKey.PageUp)});}}
Befunge 98 - 37
:0!g,:0!0!+:::**+`#@_0!+
Hello World!
The Hello World! is not a string literal. It is source code that would actually do something if you run it (I have no idea what it would do). This program works off the idea of a Befunge quine:
: duplicate number on stack (note that if there is none, then pushes a 0)
0! push 0 then not it, producing a 1
g get the character at the location (:,1) (: = number determined by the previous :)
, print that character
: duplicate number on stack (same number as first duplicate)
0!0!+:::**+ push the number 10
` compare the duplicated number with 10, if it is greater than it, push 1, else push 0.
# jump over the next character, going to the _
_ move right if the number on the top of the stack is 0, otherwise, move left
@ end program
0! push 0 then not it, producing a 1
+ add it to the counter (number on top of stack)
I'm working on a longer, more interesting version.
BrainFuck, 102 111 characters
++++++++[>++++[>++>+++>+++>+<<<<-]>+>->+>>+[<]<-]>>.>>---.+++++++..+++.>.<<-.>.+++.------.--------.>+.
Meets all of the rules.
Credit goes to Daniel Cristofani.
If we push the rules quite a bit.
Ruby, 20
puts :"Hello World!"
Technically :"Hello World!" is just the Symbol syntax.
PowerShell: 596 382
Started with Joey's idea (Excel counts 1155 characters!) and cut it by about half with some math, then down to a third with some more math and optimization of my own script.
Original: 596 characters:
My first version was fairly similar to the current one in general theory, but a bit simpler in implementation. I just took each character's ASCII code and broke it into two factors, then converted those into strings of zeroes that were as long as the factors, and made PowerShell put them back together. Some numbers were problematic since the smallest factor pairs I could come up with were pretty high - especially 'e', since 101 is prime.
$O=('000000000','00000000'),('00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000','0'),('0000','000000000000000000000000000'),('0000','000000000000000000000000000'),('000','0000000000000000000000000000000000000'),('00000000','0000'),('000','00000000000000000000000000000'),('000','0000000000000000000000000000000000000'),('000000','0000000000000000000'),('0000','000000000000000000000000000'),('0000000000','0000000000'),('000','00000000000');for($0=0;$0-lt$O.Length;$0++){$O[$0]=($O[$0][0].length,$O[$0][1].length)-join'*'|iex}[char[]]$O-join''
Current: 382 characters
The current version includes a few optimizations, and a change to more comfortably suit the spirit of the challenge.
- All factor pairs now end up 23 short of their actual target. This makes every element equate to a composite number, greatly reducing the characters required to build all of them. This alone saved about 156 characters.
- Used a
ForEach-Objectloop, via the%alias, instead offor.- Replaced the
1(though it was defining array indexes, and so not strictly a number or string literal) with'0'.length. This may cost me some characters, but it's relatively small in comparison to the overall length of the script and helps to fit in with the theme a bit better.- Optimized the multiplication routine by using a
%loop instead of individually calling out array elements.- Restructured the script so that no defined variables are needed.
-join[char[]](('0000000','0000000'),('000000','0000000000000'),('00000','00000000000000000'),('00000','00000000000000000'),('00000000','00000000000'),('000','000'),('00000000','00000000'),('00000000','00000000000'),('0000000','0000000000000'),('00000','00000000000000000'),('0000000','00000000000'),('00','00000')|%{(($_|%{$_.length})-join'*'|iex)+'00000000000000000000000'.length})
Step-by-step:
-join[char[]](...) will take an array of integers (generated by the script within), convert them to ASCII characters, and put it all together in one string output.
('0000000','0000000'),('000000','0000000000000'),... are pairs of strings of zeroes. Within a pair, the product of each string's length comes 23 short of an ASCII code needed to represent a character in 'Hello World!'.
|%{...} pipes the factor pairs into a ForEach-Object loop.
(($_|%{$_.length})-join'*'|iex) takes the length of each factor in a pair and multiplies them together.
+'00000000000000000000000'.length effectively adds 23 to the product, resulting in our target ASCII code.

Fish - 270
>"O":l(?!v~~~~~~~lo 00000v |~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !<lo0000000000000000000v |0000000 !<lo000lo~~~~~~lo~~~~~~~~lo~~~~~~~~~v;
^ <|000000000000 !<lo0000000l:oo000lo~~~~~~~~~~~~~~~~~^|000000000000000000 !<lo0000000000^ |~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !<lo;
Using |0000000000 !< to double the number of 0's put onto the stack. It will bounce off the mirror, and then jump past the <.
Python 3 – 99 chars
from re import*
c=X+U+L;_=c+M
print(bytes([X+M,-~c,_,_,_-~I,U,X+U+~M,_-~I,c+S-I,_,c,-~U]).decode())
Taking advantage of the fact that the re module uses integers as flags, e.g. re.X is 64.
Tcl
In Tcl, everything is a string.
puts Hello\ World!
If you disallow this, then this is the only valid Tcl program that can be written:
Lua, 36
print(next{Hello=0},(next{world=0}))
Python3, 16 bytes
import __hello__
Note the rule:
pre-built functions that return "Hello World!"
Does not apply since:
- That's an import and not a function
- It doesn't return anything
- It doesn't return the string but simply prints it.
Groovy, 117
def propertyMissing(p){p}
b="OOOOOOOO"
c={(char)it.size()}
a=b+b+b+b
println(Hello+c(a+b+"OOOO")+c(a)+World+c(a+"O"))
prints
Hello, World!
Perl, 96 chars
sub AUTOLOAD{my$x++;$y=$x<<$x++;print substr($AUTOLOAD,$x+$y).chr(($x<<$y)+$a++)}
&Hello;&World
It passes the rules!
Ruby 45 chars
p [:Hello,:World!].join :_20[-~0..~0].hex.chr
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,_])
Java - 147, no literals
class HelloCWorlds{static{char[]a=HelloCWorlds.class.getName().toCharArray();int
x=a.length,y=a[--x]%x;a[y]/=x/y;a[x]=a[y]--;System.out.print(a);}}
Run it like this (after compiling):
java HelloCWorlds 2>/dev/null
If you don't want to ignore stderr, then add System.exit(0); after the last semicolon. It brings the file size to 162 and makes use of the 0 literal.
Common Lisp, 35
I think nobody tried Common Lisp. Strictly speaking, a symbol is not a string literal, so this is valid:
(print(symbol-name'|Hello World!|))
Second-short if you count the Mathematica one.
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, ando!yeach applies the functionotoymultiple times: 3, 9, and 29 times respectively. 29?!?! Yes, 29!randware 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.
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);}}
Readable:
// 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);
}
}
JavaScript, 88
t=!0<<-~-~-~-~!0
r=[]
for(i in{Hello:"O",World:0})r+=i+String.fromCharCode(t++)
alert(r)
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++)
alert(r)
103
aliased String.fromCharCode
o={Hello:"O",World:0}
t=!0<<-~-~-~-~!0
c=String.fromCharCode
for(i in o)o[i]?r=i+c(t):alert(r+i+c(++t))
117
Switched if-else to ternary operator
o={Hello:"O",World:0},t=!0<<-~-~-~-~!0
for(i in o)o[i]?r=i+String.fromCharCode(t):alert(r+i+String.fromCharCode(++t))
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)
else alert(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)
alert(r)
JavaScript 100 chars (when all in one line)
Borrowing subtly from zzzzBov -- with regard to the -~ trick, not seen that before :) -- this is another way to source those pesky space and exclamation characters.
Relies on the Function.toString() ability:
c=!0<<-~-~!0;a=[];
for(i in{Hello:0,world:"O"}){a+=i+([]+function(){!0}).charAt(c);c+=c>>!0}
alert(a)
JavaScript 89 chars (when all in one line)
Also zzzzBov could slightly improve the first example by using the fact that arrays in JS collapse down to strings when used in a calculation; oh, and not creating needless vars ;)
t=!0<<-~-~-~-~!0;r=[];for(i in{Hello:"O",World:0})r+=i+String.fromCharCode(t++);alert(r)
C, 190 189 204
a,b,c,h,e,l,o;i[4],*j=i;main(_){o=*"O";a=_+_+_;b=_<<a;c=b*a+b;h=(o>>_)^o;o^=c;e=h-a;l=o-h+e;*j++=h-c|e<<b|l<<b+b|l<<c-b;*j++=o|c<<b|o+b-c<<b+b|o<<c-b;*j=o+a|l<<b|e-_<<b+b|c+_<<c-b;puts(i);}
- Must be run with exactly zero command line arguments since it depends on argc being equal to 1.
- no preprocessor macros
- Might be system endian dependant (involves cast from integer array to char array)
- Not memory safe
a,b,c,h,e,l,o; // variables
i[],m,*j=i; // array and pointer
main(_) // if no arguments are given _ will be 1
{
o=*"O"; // our one legal string constant
a=_+_+_; // a = 3
b=_<<a; // b = 8
c=b*a+b; // c = 32
h=(o>>_)^o; // h = 'h'
o^=c; // o = 'o'
e=h-a; // e = 'e'
l=o-h+e; // l = 'l'
*j++=h-c|e<<b|l<<b+b|l<<c-b; // j[0] = 'H' | 'e' << 8 | 'l' << 16 | 'l' << 24
*j++=o|c<<b|o+b-c<<b+b|o<<c-b; // j[1] = 'o' | ' ' << 8 | 'W' << 16 | 'o' << 24
*j=o+a|l<<b|e-_<<b+b|c+_<<c-b; // j[2] = 'r' | 'l' << 8 | 'd' << 16 | '!' << 24
puts(i); // puts("Hello World!\0\0\0\0")
}
Revisions:
a,b,c,h,e,l,o;i[9],*j=i;main(_){o=*"O";a=_<<_|_;b=_<<a;c=_<<b-a;h=(o>>_)^o;o^=c;e=h-a;l=o-h+e;*j++=h^c|e<<b|l<<b<<b|l<<(c-b);*j++=o|c<<b|(o+b^c)<<b<<b|o<<(c-b);*j=o+a|l<<b|e-_<<b<<b|c+_<<(c-b);printf(i);} /* original */
a,b,c,h,e,l,o;i[4],*j=i;main(_){o=*"O";a=_+_+_;b=_<<a;c=b*a+b;h=(o>>_)^o;o^=c;e=h-a;l=o-h+e;*j++=h-c|e<<b|l<<b+b|l<<c-b;*j++=o|c<<b|o+b-c<<b+b|o<<c-b;*j=o+a|l<<b|e-_<<b+b|c+_<<c-b;puts(i);} /* golfed better */
a,b,c,h,e,l,o;i[],m,*j=i;main(_){o=*"O";a=_+_+_;b=_<<a;c=b*a+b;h=(o>>_)^o;o^=c;e=h-a;l=o-h+e;*j++=h-c|e<<b|l<<b+b|l<<c-b;*j++=o|c<<b|o+b-c<<b+b|o<<c-b;*j=o+a|l<<b|e-_<<b+b|c+_<<c-b;puts(i);} /* removed illegal numeric literal in array size */
Scala 159
val o='O'/'O'
val t=o+o
val d=t+o
val f=t*t
val e=f*t
val l=' '-d
println (List(-e+o,d*e-t,l,l,' ',-'/',e,' ',' '+d,l,(e-1)*d).map(x=>(x+'O').toChar).mkString)
ungolfed:
val one='O'/'O'
val two=one+one
val drei=two+one // tri, three
val four=two*two
val eight=four<<one
val l=' ' - drei
val h=List(-eight+one, four*eight-two, l, l, ' ', -'/'+one, eight, ' ', ' ' + drei, l, (eight-1)*drei)
println (h.map (x=> (x + 'O').toChar).mkString)
C - 125 128 chars
I didn't see a proper C entry so I wrote this one:
main(){char u='O'/'O',t=u+u+u,h=u<<t,s=h<<u+u,d='O'*'O'+t,l=d+h,o='O'|s,
g['O']={'O'-h+u,d+u,l,l,o,s,o+h,o,o+t,l,d,s+u};puts(g);}
(As noted below, redefining u via main(u) can save another 9 bytes.)
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
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))))))))))));
}
Python 272 chars
s=ord('O')
a=len('0')
b=a+a
c=b+a
d=c+a
e=d+a
f=e+a
g=f+a
h=g+a
print chr(s-g)+chr(s+g*c+a)+chr(s+g*d+a)+chr(s+g*d+a)+chr(s+h*d)+chr(s-h*f+a)+chr(s+h)+chr(s+h*d)+chr(s+g*e)+chr(s+g*d+a)+chr(s+g*c)+chr(s-h*f+b)
Though I'm surprised no one tried this method
Python 31 chars
f=open(r'/0.O',)
print f.read()
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
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.
Python (169) -- FIXED
Quite a bit longer than the other solutions. But more insane.
from turtle import setworldcoordinates as w
o=0**0
t=o+o+o
b=cmp.__ne__.__doc__
print(hex.__name__[0]+str(Ellipsis)[:t]+"O"+b[-t*t-o]+w.func_name[t:t*t-o]+b[-t]).title()
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!)
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++
/*
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);
}
Clojure - 46 chars
(map print(butlast(rest(str'(Hello World!)))))
Note that Hello and World! are symbols, not literals of any kind.
Scala (357 423 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}}
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])
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}))
Lua 144 97 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.
i386 assembly (Linux, gcc syntax), 440 442 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
movwith CPP macros; eliminated the remaining 128.
Haskell - 146
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 -.
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!));}
PHP, 220 202 201 characters
<?$b=++$a+$a;$y=$b+$a;$c=$y+$b;$z=$c*$b;$s=$y*$z+$b;$h=$s*$b+$z-$b;$e=$z*$z+$a;$o=$e+$z;$l=chr($o-$y);echo chr($h).chr($e).$l.$l.chr($o).chr($s).chr($h+$z+$c).chr($o).chr($o+$y).$l.chr(--$e).chr(++$s);
Uses no numbers, string literals, RegEx literals, or pre-built functions that display "Hello World!".
It works: http://codepad.viper-7.com/OhXBkA
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 :(

