Programming Puzzles & Code Golf Stack Exchange is a question and answer site for programming puzzle enthusiasts and code golfers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

In exactly 1024 characters, no more, no less:

  • Must print Hello World.
  • Must not use unnecessary whitespace.
  • Must not use comments.

Judging should favor creativity and/or humor over simple obfuscation when voting up answers.

The earliest I will select an answer is the 11th (Sunday) of November (2012). I'm seeing some awesome entries so far, can't wait to see what else people come up with.

share|improve this question

closed as too broad by muddyfish, mbomb007, Eᴀsᴛᴇʀʟʏ Iʀᴋ, Alex A. Apr 26 at 23:00

There are either too many possible answers, or good answers would be too long for this format. Please add details to narrow the answer set or to isolate an issue that can be answered in a few paragraphs.If this question can be reworded to fit the rules in the help center, please edit the question.

What about unnecessary comments? – Strigoides Oct 31 '12 at 22:11
@Strigoides I say no unnecessary comments either. That's a pretty lame method for what I'm trying to inspire people to do. – jdstankosky Nov 1 '12 at 0:50
Welcome to CodeGolf.SE! Code-bowling is usually about getting the largest character count, but you've set a target of 1024, which more than one answer has already hit. Given that, what's the objective winning criterion? – Gareth Nov 1 '12 at 9:08
@Gareth Well, code-golf is about the shortest, so I wasn't sure what to tag this with. Have any suggestions? I figured that after a significant amount of time, the winner would either be the highest up-votes, or if no clear leader was to be found there, I'd pick the one I thought was most creative. – jdstankosky Nov 1 '12 at 10:18
As soon as I get another 20 Rep points here, I'll change it to code-curling. I like that! – jdstankosky Nov 1 '12 at 12:51

12 Answers 12

up vote 43 down vote accepted

C# (and without “Hello World” anywhere)

Code-golfed, so that obviously no unnecessary whitespace is used:

using System;using System.IO.Compression;using System.Runtime.Serialization;using System.Runtime.Serialization.Json;using System.Linq;using System.Net;using System.Text.RegularExpressions;class C{static void Main(){var g=WebRequest.Create("");var r=(HttpWebResponse)g.GetResponse();if(r.StatusCode==HttpStatusCode.OK){var s=r.GetResponseStream();foreach(var a in r.ContentEncoding.ToLowerInvariant().Split(',').Reverse())switch(a){case"gzip":s=new GZipStream(s,CompressionMode.Decompress);break;case"deflate":s=new DeflateStream(s,CompressionMode.Decompress);break;default:throw new InvalidOperationException();}var d=new DataContractJsonSerializer(typeof(R));var q=(R)d.ReadObject(s);var e=new Regex("<code>([^<]*)</code>");var m=e.Match(q.I[0].B);Console.WriteLine(m.Groups[1].Value);}}}[DataContract]public class R{[DataMember(Name="items")]public I[]I{get;set;}}[DataContract]public class I{[DataMember(Name="body")]public string B{get;set;}}

Formatted for readability:

using System;
using System.IO.Compression;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Json;
using System.Linq;
using System.Net;
using System.Text.RegularExpressions;

class C
    static void Main()
        var g = WebRequest.Create("");
        var r = (HttpWebResponse)g.GetResponse();
        if (r.StatusCode == HttpStatusCode.OK)
            var s=r.GetResponseStream();
            foreach (var a in r.ContentEncoding.ToLowerInvariant().Split(',').Reverse())
                case "gzip":
                    s = new GZipStream(s,CompressionMode.Decompress);
                case "deflate":
                    s = new DeflateStream(s,CompressionMode.Decompress);
                    throw new InvalidOperationException();
            var d = new DataContractJsonSerializer(typeof(R));
            var q = (R)d.ReadObject(s);
            var e = new Regex("<code>([^<]*)</code>");
            var m = e.Match(q.I[0].B);

public class R
    public I[] I { get; set; }

public class I
    public string B { get; set; }

The program retrieves this question from Code Golf using Stack Exchange API, finds the first piece of text formatted as code (which, in case of this question, is the “Hello World” text), and prints it out.

share|improve this answer
That's a pretty creative way to do it! – jdstankosky Nov 1 '12 at 12:49
This is epic. Very, very cool. – Beska Nov 1 '12 at 13:49
Just hope no one trolls the question to change the question's formatting.... – Roddy of the Frozen Peas Nov 1 '12 at 15:46
created a profile on code-golf just so I could upvote this question. Epic – ryan Nov 1 '12 at 16:58
Same as Ryan - added code-golf just to upvote this. Well played. – RelicScoth Nov 13 '12 at 13:55



This is 1024 characters, excluding the whitespace I added to make a nice 64*16 block.

The strategy is as follows:

  • Fill the first few bytes with characters "Hello World", except each byte is 5 too small. This is done in all but the last 16 characters. The first byte is left blank in order to not have the pointer go out of bounds later.

  • Bring the pointer back to the start, adding 5 to each byte using [+++++<]

  • Go through the characters, print them and zero the byte using >[.[-]>]

share|improve this answer
This looks like some form of minimalist art, I like it! – jdstankosky Nov 1 '12 at 12:50
Gah, ye beat me to it. – a sandwhich Nov 3 '12 at 3:15

JavaScript (1024 bytes...)

No unnecessary whitespace? What about unnecessary semicolons that JavaScript doesn't need at all? Let's add those semicolons to make people like Crockford happy.

;;;;;;;;;;;;;;;;;;;console.log('Hello World');;;;;;;;;;;;;;;;;;;

Yes, I'm aware that this is abuse of rules.

share|improve this answer
You could also use curly braces, like {{{{{console.log("Hello, World!")}}}}} – Peter Olson Nov 1 '12 at 17:18
+1 for abuse of the rules – heinrich5991 Nov 1 '12 at 17:41
+1 for lolololol – Matthew Roh Jul 4 at 13:05

Mathematica 1024 chars

 StringTake[ElementData[][[2]], 3] <> 
  StringTake[WordData["high", "Antonyms"][[2, 2, 1]], 2] <> 
  FromCharacterCode[Power[2, 5]] <> 
  StringTake[GraphData[][[Prime@705]], 2] <> 
  StringTake[AstronomicalData["Planet"][[1]], {3}] <> "ld"], 
  StringTake[ElementData[][[2]], 3] <> 
   StringTake[WordData["high", "Antonyms"][[2, 2, 1]], 2] <> 
   FromCharacterCode[Power[2, 5]] <> 
   StringTake[GraphData[][[Prime[705]]], 2] <> 
   StringTake[AstronomicalData["Planet"][[1]], {3}] <> "ld"]], 
   2] /. {a_, b_} :> DirectedEdge[a, b],

EdgeLabelStyle -> Power[2, 4], 
EdgeLabels -> (Partition[
   Riffle[l = 
      StringTake[ElementData[][[2]], 3] <> 
       StringTake[WordData["high", "Antonyms"][[2, 2, 1]], 
        1 + 1] <> FromCharacterCode[Sqrt[Sqrt[1048576]]] <> 
       StringTake[GraphData[][[Prime[705]]], 2] <> 
       StringTake[AstronomicalData["Planet"][[1]], {3}] <> "ld"], 
    Rest@l], 2] /. {a_, b_} :> DirectedEdge[a, b]) + 
Power[{1, 8, 27, 64, 125, 216, 343, 512, 729, 1000}, 
 1/3] /. {Plus[a_, b_] :> Rule[b, a]}, 
VertexLabelStyle -> Directive[RGBColor[0, 0, 1], Large], 
VertexLabels -> "Name", ImagePadding -> Power[5, 2], 
ImageSize -> 2^2*5^2*7]


De-bowled (partially)

For those who don't have access to Mathematica's curated data:

 WordData["high", "Antonyms"][[2, 2, 1]]





"Hel" (from "Helium") + "lo" (from "low") + " " (FromCharacterCode[32]) + "Wo" (from "WongGraph") + "r" (from "Mercury") + "ld"

yields the string "Hello World".

The string is split into characters, each of which becomes a vertex in the following graph:

Graph[{"H" \[DirectedEdge] "e", "e" \[DirectedEdge] "l", 
 "l" \[DirectedEdge] "l", "l" \[DirectedEdge] "o", 
 "o" \[DirectedEdge] " ", " " \[DirectedEdge] "W", 
 "W" \[DirectedEdge] "o", "o" \[DirectedEdge] "r", 
 "r" \[DirectedEdge] "l", "l" \[DirectedEdge] "d"},

EdgeLabelStyle -> 16, 
EdgeLabels -> {"H" \[DirectedEdge] "e" -> 1, "e" \[DirectedEdge] "l" -> 2, "l" \ [DirectedEdge] "l" -> 3, 
"l" \[DirectedEdge] "o" -> 4, "o" \[DirectedEdge] " " -> 5, 
" " \[DirectedEdge] "W" -> 6, "W" \[DirectedEdge] "o" -> 7, 
"o" \[DirectedEdge] "r" -> 8, "r" \[DirectedEdge] "l" -> 9, 
"l" \[DirectedEdge] "d" -> 10}, 
VertexLabelStyle -> Directive[Blue, Large], VertexLabels -> "Name", ImagePadding -> 25]
share|improve this answer
Wow... that's awesome. – jdstankosky Nov 1 '12 at 12:47
+1 for insanity – Mr.Wizard Apr 6 '13 at 13:44

Shell :)

echo '
share|improve this answer
The 'W' is a little messed up. – luser droog Feb 26 '13 at 8:52

C, 1024 characters

Here's an adaptation of my answer to another "Hello, world" question:

I'm not sure what's "unnecessary whitespace". I used spaces, indentation and line breaks to make code nicely formatted, but strictly speaking most of it is unnecessary. I did count the whitespace in the 1024 chars.

EDIT: Changed to return! in the first line. Nicer this way, I think.

#include <stdio.h>
int main(int argc, char **argv, char **envp) {

Another one - Python this time

1024 characters, 944 of them are whitespace, all necessary.

print 11*'%c'%tuple(len(x)+8for x in'                                                                /                                                                                             /                                                                                                    /                                                                                                    /                                                                                                       /                        /                                                                               /                                                                                                       /                                                                                                          /                                                                                                    /                                                                                            '.split('/'))
share|improve this answer
lmao: "fatal error C1026: parser stack overflow, program too complex" – im so confused Nov 1 '12 at 15:29
@AK4749, works in – ugoren Nov 1 '12 at 16:13
damn visual studio lol – im so confused Nov 1 '12 at 16:51
+1 for breaking visual studio – heinrich5991 Nov 1 '12 at 17:40


I had to modify the max length of scripts on for this :)

))))))))))))))))))))))))))))))))))))))))))))))))))))' '1))))))))

Run the program online here.

share|improve this answer
+1 for modifying the max length of golfscript scripts for this... – ceased to turn counterclockwis Nov 1 '12 at 17:28


main=putStrLn hello_world
 where hello_world=show H++ello_world
        where ello_world=show E++llo_world
               where llo_world=show L++lo_world
                      where lo_world=show L++o_world
                             where o_world=show O++_world
                                    where _world=show 𝞝++world
                                           where world=show W++orld
                                                  where orld=show O++rld
                                                         where rld=show R++ld
                                                                where ld=show L++d
                                                                       where d=show D
data Letter=H|E|L|O|𝞝|W|R|D
instance Show Letter where
 show H=["Hello, World!"!!0]
 show E=["Hello, World!"!!1]
 show L=["Hello, World!"!!2]
 show O=["Hello, World!"!!4]
 show 𝞝=["Hello, World!"!!6]
 show W=["Hello, World!"!!7]
 show R=["Hello, World!"!!9]
 show D=["Hello, World!"!!11]

1024 characters, including the (necessary, Haskell is indentation-sensitive!) whitespace. (Though you could remove the line breaks entirely, but who wants an unreadable one-liner? Even now, it's hard enough to guess what this program does, what with the lack of comments...)

share|improve this answer

Javascript, cut and paste into console (chrome browser of course) on this page to see the page disappear!

function pad_with_zeroes(number, length){
var my_string = '' + number;
while (my_string.length < length){
my_string = '0' + my_string;
return my_string;
var code_tags = document.getElementsByTagName('code');
var hello_world = code_tags[0].innerHTML;
var body_tags = document.getElementsByTagName('body');
var body = 'NULL';
body = body_tags[0];
var html_input = "<div id='div_that_holds_hello_world' style='font-size:50px; color:#987324; width: 900px; height: 900px; text-align: center;'><span id='hello_world_span'>" +hello_world+ "</span></div>";
body.innerHTML = html_input;
var span = document.getElementById('hello_world_span');
var div = document.getElementById('div_that_holds_hello_world');
var j_c = 1;
var i_c = 0;
var setIn = setInterval(function(){
if(i_c%2 == 0){ = 'none';
}else{ = 'block';
if(i_c%50 != 0){ = j_c + 'px';
if(i_c < 1000000){ = '#'+ pad_with_zeroes(i_c, 6);
i_c = 0;
j_c = 0;
}, 500);
share|improve this answer
@JoeTuskan part of that is javascript, like when I create the html for html_input. And part was just cause I was trying to do this very quickly :) – ryan Nov 1 '12 at 18:36
@JoeTuskan there fixed them all (I think) they were not in there to get me on the char count. – ryan Nov 1 '12 at 18:38
comment removed. I'd upvote again if possible :) – Joe Tuskan Nov 1 '12 at 19:22

Python 2 - 1024

print''.join(chr(32if c[0]>"z"else """
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy
eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam
voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita
kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem
ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod
tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At
vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd
gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum
dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor
invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero
eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no
sea takimata sanctus est Lorem ipsum dolor sit amet. Duis autem vel enum...
""".count(c[0]+c[1])+99)for c in zip(' yddd~ doda','t iio~doliu')).title()

Writing this program was quite a tedious process, the length of the algorithm (first and last line) impacts the length of the dummy text (to meet the required total number of 1024 characters), which in turn impacts the count of certain substrings... And even worse: Some counts might just not occur with any substring, so I need to adjust the general bias 99, which impacts all other letters. But happily, a helper script is always quickly implemented. :)

share|improve this answer


Lipsum Test with a regex:

"Hello World|Ta what. Soft lad mardy bum that's champion. Tha knows chuffin' nora tha knows tha knows mardy bum shurrup. Where's tha bin. Any rooad ne'ermind. Is that thine cack-handed ah'll gi' thee a thick ear. Ah'll gi' thee a thick ear. Gerritetten tintintin ah'll learn thi shurrup chuffin' nora. Sup wi' 'im. Nah then soft southern pansy tintintin breadcake t'foot o' our stairs how much. Shu' thi gob be reet th'art nesh thee ah'll gi' thee a thick ear that's champion. Shu' thi gob t'foot o' our stairs tha daft apeth where's tha bin ah'll gi' thi summat to rooer abaht. Wacken thi sen up eeh eeh. Shu' thi gob tha what that's champion soft southern pansy ah'll learn thi a pint 'o mild. Appens as maybe gi' o'er nobbut a lad nobbut a lad.Big girl's blouse a pint 'o mild. Big girl's blouse ah'll learn thi. A pint 'o mild. How much ah'll gi' thi summat to rooer abaht michael palin nay lad. Gerritetten a pint 'o mild be reet nay lad. Nay lad how much ee by gum. 1234567I love feet so much.".match(/Hello World/)[0]

The regex: .match(/Hello World/)[0]

share|improve this answer
Lots of unnecessary whitespace. – ugoren Nov 1 '12 at 22:14
@ugoren, would you prefer underscores? – Joe Tuskan Nov 2 '12 at 1:48
Nice! You could also replace the regex match by a .slice(-N) – xem Dec 11 '13 at 10:53


Kinda cheap:

print"""Hello World"""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""
share|improve this answer
Could have livened it up a bit with adding some arbitrary strings, and the substringing them off – Cruncher Dec 4 '13 at 19:00

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