Hello World in 1024 characters



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.


Posted 2012-10-31T19:27:56.033

Reputation: 1 474

Question was closed 2016-04-26T23:00:53.130

What about unnecessary comments? – Strigoides – 2012-10-31T22:11:36.547

@Strigoides I say no unnecessary comments either. That's a pretty lame method for what I'm trying to inspire people to do. – jdstankosky – 2012-11-01T00:50:55.313


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 – 2012-11-01T09:08:48.893

@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 – 2012-11-01T10:18:09.127

The problem with 'highest upvotes' or 'most creative' as winning criteria is that no-one really knows what will garner up-votes or what you personally will find creative. Unfortunately, I can't think of an objective winning criteria other than 'first to post' which would discourage further answers. As to the tag - I suppose if we're aiming to get as close as possible to a fixed target we could have [code-boules] or [code-curling] :-) – Gareth – 2012-11-01T12:40:50.007

9As soon as I get another 20 Rep points here, I'll change it to code-curling. I like that! – jdstankosky – 2012-11-01T12:51:32.523

just like curling, i don't see the purpose of this. what is the winning criteria? – ardnew – 2012-11-01T21:02:07.930

@ardnew while I don't personally like curling, its just like any other sport. The purpose is to have fun, and for those competing to win. There are rules posted, so the winning criteria would be the person with the most upvotes that actually followed the rules. – Ryan – 2012-11-01T21:53:21.713

Quothe the FAQ: "All questions on this site, whether a programming puzzle or a code golf, should have [an] objective primary winning criterion, so that it is possible to indisputably decide which entry should win." Creativity and humor are not "objective". There seems to a lot of desire to have non-objective contests here, but this should be taken up on meta. Closing for now. – dmckee --- ex-moderator kitten – 2012-11-01T22:06:03.453

This type of question has come up before, and the moderators will close it if it breaks any rules no matter what, unfortunately. See http://codegolf.stackexchange.com/questions/6707/print-a-line-10-times-in-the-most-creative-way-possible

– beary605 – 2012-11-01T23:31:09.180

While I will read comments here and flag messages, I was really hoping that someone would take this up on meta. One user (luser droog) has opened a (related, I guess) topic as "Isn't there some way to have "just-for-fun" questions?", and that is certainly a good place to bring idea. Meta would also be the place to argue for changing the FAQ.

– dmckee --- ex-moderator kitten – 2012-11-02T02:33:43.277

I have also added Should we consider dropping or modifying the "objective winning criteria" requirement?. Go to town.

– dmckee --- ex-moderator kitten – 2012-11-02T03:00:56.460

1The answers on this question have a ridiculous number of upvotes. I say we reopen. I suggested code-shuffleboard on meta quite a while ago, and this gives a good example of the creativity that can go into solutions for that type of challenge. – boothby – 2013-12-04T07:46:38.717



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("https://api.stackexchange.com/2.1/questions/8859?site=codegolf&filter=withbody");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("https://api.stackexchange.com/2.1/questions/8859?site=codegolf&filter=withbody");
        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.


Posted 2012-10-31T19:27:56.033

Reputation: 1 148

That's a pretty creative way to do it! – jdstankosky – 2012-11-01T12:49:45.160

This is epic. Very, very cool. – Beska – 2012-11-01T13:49:05.713

7Just hope no one trolls the question to change the question's formatting.... – Roddy of the Frozen Peas – 2012-11-01T15:46:08.937

2created a profile on code-golf just so I could upvote this question. Epic – Ryan – 2012-11-01T16:58:00.907

1Same as Ryan - added code-golf just to upvote this. Well played. – RelicScoth – 2012-11-13T13:55:40.623

I want to edit the question so bad now. – Cruncher – 2013-12-04T18:53:16.863




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 >[.[-]>]


Posted 2012-10-31T19:27:56.033

Reputation: 5 150

3This looks like some form of minimalist art, I like it! – jdstankosky – 2012-11-01T12:50:15.033

Gah, ye beat me to it. – a sandwhich – 2012-11-03T03:15:28.357


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.

Konrad Borowski

Posted 2012-10-31T19:27:56.033

Reputation: 11 185

3You could also use curly braces, like {{{{{console.log("Hello, World!")}}}}} – Peter Olson – 2012-11-01T17:18:54.753


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]


Posted 2012-10-31T19:27:56.033

Reputation: 24 524

2Wow... that's awesome. – jdstankosky – 2012-11-01T12:47:37.593


Shell :)

echo '

luser droog

Posted 2012-10-31T19:27:56.033

Reputation: 4 535

7The 'W' is a little messed up. – luser droog – 2013-02-26T08:52:11.237


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('/'))


Posted 2012-10-31T19:27:56.033

Reputation: 16 527

6lmao: "fatal error C1026: parser stack overflow, program too complex" – im so confused – 2012-11-01T15:29:23.600

@AK4749, works in ideone.com.

– ugoren – 2012-11-01T16:13:12.087

damn visual studio lol – im so confused – 2012-11-01T16:51:12.040



I had to modify the max length of scripts on http://golfscript.apphb.com/ for this :)

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

Run the program online here.

Cristian Lupascu

Posted 2012-10-31T19:27:56.033

Reputation: 8 369

7+1 for modifying the max length of golfscript scripts for this... – ceased to turn counterclockwis – 2012-11-01T17:28:11.063



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

ceased to turn counterclockwis

Posted 2012-10-31T19:27:56.033

Reputation: 5 200


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){
span.style.display = 'none';
span.style.display = 'block';
if(i_c%50 != 0){
div.style.fontSize = j_c + 'px';
if(i_c < 1000000){
div.style.color = '#'+ pad_with_zeroes(i_c, 6);
i_c = 0;
j_c = 0;
}, 500);


Posted 2012-10-31T19:27:56.033

Reputation: 190

@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 – 2012-11-01T18:36:19.653

@JoeTuskan there fixed them all (I think) they were not in there to get me on the char count. – Ryan – 2012-11-01T18:38:19.633

comment removed. I'd upvote again if possible :) – Joe Tuskan – 2012-11-01T19:22:52.473


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


Posted 2012-10-31T19:27:56.033

Reputation: 5 307

Wow. Never thought lorem ipsum would result in hello world. – Matthew Roh – 2017-02-19T15:59:19.473



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]

Joe Tuskan

Posted 2012-10-31T19:27:56.033

Reputation: 171

Lots of unnecessary whitespace. – ugoren – 2012-11-01T22:14:12.523

4@ugoren, would you prefer underscores? – Joe Tuskan – 2012-11-02T01:48:26.527

Nice! You could also replace the regex match by a .slice(-N) – xem – 2013-12-11T10:53:19.463



Kinda cheap:

print"""Hello World"""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""+""


Posted 2012-10-31T19:27:56.033

Reputation: 191

4Could have livened it up a bit with adding some arbitrary strings, and the substringing them off – Cruncher – 2013-12-04T19:00:49.187