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
  1. Your program should output exactly: Hello world!!! with or without linefeed after.
  2. Your program should take no input.
  3. Sourcecode character distribution must be correct according to:
    • The number of numeric characters (0-9) must be exactly one fibonacci sequence number.
    • The number of other non-numeric characters !(0-9) in the sourcecode must be exactly the fibonacci sequence number before the above fibonacci sequence number.

Four examples of valid character distribution in sourcecode:

  • 13 numeric, 8 non-numeric characters.
  • 34 numeric, 21 non-numeric characters.
  • 55 numeric, 34 non-numeric characters.
  • 89 numeric, 55 non-numeric characters.

This is code-golf, shortest code in bytes wins! Good luck!

Edit: As this question has constraints on the sourcecode size in combination with being code-golf the accepted answer (if more than one share the equal winning character length) will be the answer with most votes (and least character-count): 2014-03-01.

share|improve this question
Thus, all solutions have a character count which is a fibonacci number. – Howard Jan 18 '14 at 9:02
Here is a program to validate answers (paste the code into the input box.) – Justin Jan 18 '14 at 9:19
Is it even possible to do this in less than 55 characters? The required output has 14 chars, and I can't think of a language that can use numbers to output chars without using at least one character per char. – Justin Jan 18 '14 at 9:24
@Plarsen definitely not OK – Jan Dvorak Jan 18 '14 at 9:37
Okay, I will not change the rules then :) – Plarsen Jan 18 '14 at 9:38

19 Answers 19

up vote 27 down vote accepted

Windows Command Prompt - 34, 8, 5 chars, (2 below)

*These ones may or may not be breaking rule 2, but here it is anyway


Name the file:

&start call echo Hello world!!!&exit -b .cmd

Now lets corrupt the file-system a little - 2 chars (or less if you want)


Name the file (using your preferred unorthodox method):

"&start call echo Hello world!!!&exit&.cmd

How does this work:

Since cmd scripts are invoked with 'cmd.exe /C "%1" %*' the executed command will be:

cmd.exe /C "c:\PATH_TO_THE_SCRIPT\"&start call echo Hello world!!!&exit&.cmd"

which will in the following order:

  • Fail to execute "c:\PATH_TO_THE_SCRIPT\"
  • Open a new shell printing Hello world!\n
  • Exit the original shell
share|improve this answer
Wow! I think we had got a winner if the rules wasn't saying no input. +1 anyway for the outside-of-box thinking. – Plarsen Jan 18 '14 at 12:37
Code golf with Windows CMD... +1. Also, it is arguable that "no input" could have meant "no reading STDIN" :P – Camilo Martin Jan 19 '14 at 5:06
That's an interesting trick for other code golfs too… write the real code in the file name and use something like eval $0 to execute it <rolleyes> – Tobia Jan 19 '14 at 18:36
That's impossible!! 5 chars? Really interesting approach – Plarsen Jan 20 '14 at 11:46
In fact, I've just posted a 2 char solution below. – Tobia Jan 20 '14 at 13:32

MySQL, 34


This is a MySQL expression that evaluates to Hello world!!!, assuming the sql_mode setting includes PIPES_AS_CONCAT. It contains exactly 21 digits and 13 non-digits.

Whether this qualifies as a valid entry, I leave it to the jury.


mysql> select x'48656C6C6F20776F726C642121'||'!';
| x'48656C6C6F20776F726C642121'||'!' |
| Hello world!!!                     |
1 row in set (0.00 sec)
share|improve this answer
What the... CMD and SQL winning code golf?? – Camilo Martin Jan 19 '14 at 5:08
The select and ; are arguably part of the statement, but still a clever solution. – primo Jan 21 '14 at 5:57
@primo they are, that's why I'm unsure whether this qualifies. But I thought I'd post it for hilarity ;-) – Tobia Jan 21 '14 at 9:35

C64 BASIC, 55

enter image description here

For fun and nostalgia!

share|improve this answer

GolfScript, 55 characters

[72 101 108 108 111 32 119 111 114 108 100 33 {.}2*]''+

Didn't find a way to have a 34 characters solution, thus I created this one.

share|improve this answer

Befunge 98 - 55

a"!!!dlrow olleH"ek,@1235813213455891442333776109871597

Decided to do it with a newline, since it doesn't cost anything. The numbers are the concatenated values of the Fibonacci sequence.

share|improve this answer

Python 34-55

print "Hello world%s"%("!"*int(3.141592653589793238462643383279502884197169399375105820))

Yes. I waste them digits. What are you gonna do about it?

share|improve this answer
Who knew pi~3 would be so useful! – Kyle Kanos Jan 18 '14 at 15:52
The question says 21 non-numeric plus 34 numeric, your answer is 34 non-numeric plus 21 numeric. – ace Jan 18 '14 at 15:55
@ace thanks, fixing – Reut Sharabani Jan 18 '14 at 16:17
the "hello world" should be "Hello world"; that is capitalize the h. – Justin Jan 18 '14 at 18:04

C (89 characters)

main() {
int i[0000000000000004]={1819043144,1870078063,560229490,2566922529};

While the above is valid, unfortunately, my efforts to compact it with the following program doesn't meet the spec. I feel like it's worth looking at and maybe someone else can shorten it a bit though (64 characters, 37 numerals, 27 non-numerals). To compile it, you'll have to use clang and with -fms-extensions.

share|improve this answer
Compound literals, is the name for what you're looking for. I'm trying to use them to get this down to 21 characters now! – charmlessCoin Jan 20 '14 at 1:51
The lowest non-numeric count I can reach is 26, by making i global (omitting int). Using long can save commas, but costs more. 21 is very far. – ugoren Jan 20 '14 at 13:20
Yeah, it's a lot of wasted space. Using that little trick, I can get it to main(){puts((int[]){1819043144,1870078063,560229490,8481});} but that's still 60 characters. If I could eliminate just a few more... Edit: wow, so globals don't have to have a declaration? Who knew? – vmrob Jan 20 '14 at 19:55
@vmrob, globals have to have a declaration. But the type defaults to int, so a; is equivalent to int a;. – ugoren Jan 21 '14 at 20:40
@ugoren I knew that they had to have a declaration, I just didn't realize it defaulted to int! – vmrob Jan 21 '14 at 20:42

Windows PowerShell (probably also Bash), 55

curl -L

You didn't say anything about network access, so here's a dirty solution. I've got a URL with few enough letters on the second try. Unfortunately, It's still 21 non-digits, needing 34 digits to be used or wasted.

share|improve this answer
You know you can edit the links right? – Timtech Jan 18 '14 at 15:03
What do you mean, edit? Also, I wouldn't get this under 13 letters in any case. – Jan Dvorak Jan 18 '14 at 15:05
You can hit the pencil next to "Copy" and edit the link. If you do, all the old versions will still work. – Timtech Jan 18 '14 at 22:18
Shortened to 34! curl – Dom Hastings Jan 19 '14 at 8:55

sh, 55

echo Hello world!!! #1234567890123456789012345678901234
share|improve this answer

Korn Shell, 21

echo $0

The script must be called "Hello world!!!" :)

share|improve this answer

PHP (55 bytes)

This program uses binary (wow, it's the third time I reuse the same trick). 21 non-numeric characters, 34 numeric characters. No letters, because letters are boring.


0000000: 3c3f 3d7e b79a 9393 90df 8890 8d93 9bde  <?=~............
0000010: dede f53b 2331 3233 3435 3637 3839 3031  ...;#12345678901
0000020: 3233 3435 3637 3839 3031 3233 3435 3637  2345678901234567
0000030: 3839 3031 3233 34                        8901234
share|improve this answer
@JanDvorak: I'm almost sure I read "before or after". Oh well, let me fix it then. – xfix Jan 18 '14 at 10:38

Mathematica 55

"Hello World!!!"(34+21!)/000000000051090942171709440034


Hello World!!!
share|improve this answer

Sclipting (34 characters)


Unfortunately Sclipting doesn’t use any ASCII characters at all, so I have to pad the program with 21 useless number characters :(

share|improve this answer

Bash, 2 chars

Very well, in the unlikely case Robert's answer is not disqualified, here's mine:


Name the file echo Hello world!!! and execute with sh.

share|improve this answer



digits : 55 non digits: 34

share|improve this answer
Note there are no comments in the solution. only code. – Elisha Jan 21 '14 at 21:48

J (55 characters)

(34 numeric + 21 non-numeric)

(72 101 108 108 111 32 119 111 114 108 100{a.), 3#33{a.
share|improve this answer

Forth or Ruby, 55

(34 numeric + 21 non-numeric)


." Hello world!!!" \ 3141592653589793238462643383279502


puts"Hello world!!!"#3141592653589793238462643383279502

Using comments to pad feels dirty, but those are valid answers.

share|improve this answer

Windows Batch

echo Hello World!!!::0123456789012345678901234567890123
share|improve this answer
Wow. This is so much different from my sh solution. – ace Jan 18 '14 at 16:08


the h prints hello and the rest is just numbers

share|improve this answer
This is not distributed according to Fibonacci, also, the output is not exactly Hello world!!! – Timtech Jan 23 '14 at 12:38

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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