91
\$\begingroup\$

Dilbert is awesome
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.

\$\endgroup\$
24
  • 1
    \$\begingroup\$ I hope by "numbers" you mean "numeric constants", because there probably wouldn't be much programming left without. \$\endgroup\$
    – J B
    Mar 11, 2011 at 21:42
  • 5
    \$\begingroup\$ 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. \$\endgroup\$ Mar 11, 2011 at 22:29
  • 4
    \$\begingroup\$ -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. \$\endgroup\$ Mar 11, 2011 at 22:35
  • 2
    \$\begingroup\$ @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. \$\endgroup\$ Mar 11, 2011 at 23:39
  • 2
    \$\begingroup\$ 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. \$\endgroup\$
    – Timwi
    Mar 12, 2011 at 21:12

109 Answers 109

1 2 3
4
0
\$\begingroup\$

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

  1. Generate the numbers 1,2,3,4,7, and 8 from "O" and 0 and common functions

  2. Concatenate the numbers together as strings to form ascii values

  3. Put ascii values in an array

  4. Join the array into a string using an empty string (repeat "o" 0 times) as the delimiter

  5. 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"))
\$\endgroup\$
0
\$\begingroup\$

Javascript - 129 chars

s=[,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,];c=String.fromCharCode;alert(Object.keys({Hello:s,World:s}).join(c(s.length))+c(++s.length));
\$\endgroup\$
2
  • \$\begingroup\$ You can make your code shorter by replacing console.log with alert and by removing the space between : and null. Also, you forgot to add the exclamation mark at the end of the output. \$\endgroup\$
    – ProgramFOX
    Aug 28, 2014 at 14:34
  • \$\begingroup\$ Okay, I've corrected it. \$\endgroup\$ Aug 28, 2014 at 14:48
0
\$\begingroup\$

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.

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

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!".

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

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

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

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

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

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).
\$\endgroup\$
0
\$\begingroup\$

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))))     ; "!"
\$\endgroup\$
0
\$\begingroup\$

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

\$\endgroup\$
2
  • \$\begingroup\$ 'something is a symbol, not string literal. Symbols evaluate to their names, which are string literals \$\endgroup\$
    – Michael M
    Sep 30, 2016 at 6:19
  • \$\begingroup\$ don't symbols have all caps? \$\endgroup\$ Oct 26, 2016 at 5:13
0
\$\begingroup\$

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:

enter image description here

If you accept "garbage" around the message, the code could be made shorter by three bytes.

\$\endgroup\$
2
  • 2
    \$\begingroup\$ loophole: As "part of the code", it´s a string literal; no matter how you call it. It is also no program, not even a code snippet. It´s actually just plain text. \$\endgroup\$
    – Titus
    Jan 28, 2017 at 12:33
  • \$\begingroup\$ @Titus No, it most definitely is not a string literal - in ZX Spectrum BASIC there is a very sharp difference between code and literals - numbers and strings (also in how they are represented in RAM). And this is none of them, it's neither a string variable. \$\endgroup\$ Jan 28, 2017 at 13:47
0
\$\begingroup\$

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

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.

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

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.

Try it online!

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

(,) 375 344 334 Chars or \$334\log_{256}(3)\approx66.17\$ Bytes

(()()(),()()()()()()())((),(()()())()()())((()),(())(())(()))(((())),((()))((()))(()))(,,,(((())))()())(()(),(((())))((()))())(,,,(()()))(,,,(()())(()()()),(),,()())(,,,(()())(()))(,,,((()))(())()()()())(,,,((()))()())(,,,(((())))(())(()()()))(,,,(()())(()))(,,,(()())(())()()())(,,,(()())(()()()))(,,,(((())))((())))(,,,((()))()()())

Same as my normal answer.
Tio

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

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")))

Try It Online!

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

YASEPL, 184 bytes

=O$+^^**++++++++›+++++++++++++++++++++++++++++›+++++++››+++›$+++++++++++**----›------------›*+++++++++++++++++++++++›$+******-----------------›+++›------›--------›$*****+›

char codes my beloved

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

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)});}}
\$\endgroup\$
3
  • \$\begingroup\$ using C = System.ConsoleKey; would save a number of chars. \$\endgroup\$
    – zzzzBov
    Jan 28, 2014 at 22:55
  • \$\begingroup\$ I don't think it will. Enum constants can only be referred through Enum. \$\endgroup\$
    – microbian
    Jan 28, 2014 at 23:02
  • \$\begingroup\$ Next time, please compile your programs before posting them. This needs a using System and Main needs to be capitalized. However, the suggestion made by @zzzzBov is correct; you can use using C=System.ConsoleKey; to abbreviate the code massively. Furthermore, you can remove the parentheses around the lambda parameters. That takes it down to 275. \$\endgroup\$
    – Timwi
    Feb 5, 2014 at 0:48
-1
\$\begingroup\$

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.

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

Windows Batch (17)

Inspired by Joey's answer.

echo Hello World!
\$\endgroup\$
1
  • 1
    \$\begingroup\$ Does Hello World! not qualify as a string literal here? Curious. \$\endgroup\$ Jul 7, 2014 at 22:11
1 2 3
4

Your Answer

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

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