Take the 2-minute tour ×
Programming Puzzles & Code Golf Stack Exchange is a question and answer site for programming puzzle enthusiasts and code golfers. It's 100% free, no registration required.
  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
5  
Thus, all solutions have a character count which is a fibonacci number. –  Howard Jan 18 at 9:02
1  
Here is a program to validate answers (paste the code into the input box.) –  Quincunx Jan 18 at 9:19
1  
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. –  Quincunx Jan 18 at 9:24
1  
@Plarsen definitely not OK –  Jan Dvorak Jan 18 at 9:37
1  
Okay, I will not change the rules then :) –  Plarsen Jan 18 at 9:38

19 Answers 19

up vote 25 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

%~099

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)

A1

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
1  
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 at 12:37
1  
Code golf with Windows CMD... +1. Also, it is arguable that "no input" could have meant "no reading STDIN" :P –  Camilo Martin Jan 19 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 at 18:36
    
That's impossible!! 5 chars? Really interesting approach –  Plarsen Jan 20 at 11:46
    
In fact, I've just posted a 2 char solution below. –  Tobia Jan 20 at 13:32

MySQL, 34

x'48656C6C6F20776F726C642121'||'!'

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.

Example

mysql> select x'48656C6C6F20776F726C642121'||'!';
+------------------------------------+
| x'48656C6C6F20776F726C642121'||'!' |
+------------------------------------+
| Hello world!!!                     |
+------------------------------------+
1 row in set (0.00 sec)
share|improve this answer
4  
What the... CMD and SQL winning code golf?? –  Camilo Martin Jan 19 at 5:08
    
The select and ; are arguably part of the statement, but still a clever solution. –  primo Jan 21 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 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 at 15:52
1  
The question says 21 non-numeric plus 34 numeric, your answer is 34 non-numeric plus 21 numeric. –  ace Jan 18 at 15:55
    
@ace thanks, fixing –  Reut Sharabani Jan 18 at 16:17
1  
the "hello world" should be "Hello world"; that is capitalize the h. –  Quincunx Jan 18 at 18:04

C (89 characters)

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

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.

main(){puts((__int128[]){671944380693508453879479574226248i8});}
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 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 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 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 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 at 20:42

Windows PowerShell (probably also Bash), 55

curl -L bit.ly/1b9q8ve?1=123581321345589144233377610987

You didn't say anything about network access, so here's a dirty solution. I've got a bit.ly 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 bit.ly links right? –  Timtech Jan 18 at 15:03
    
What do you mean, edit? Also, I wouldn't get this under 13 letters in any case. –  Jan Dvorak Jan 18 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 at 22:18
1  
Shortened to 34! curl 37.187.42.18/?hw=112358132134 –  Dom Hastings Jan 19 at 8:55

sh, 55

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

Korn Shell, 21

echo $0
#123456789012

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.

xxd

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 at 10:38

Mathematica 55

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

Output

Hello World!!!
share|improve this answer

Sclipting (34 characters)

丟0000000000긒괡뉆롲닷댠닶롬뉔밈0000000000併0反

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

Python

print'092020090920200948656c6c6f20776f726c642121212009200909200920'.decode('hex').strip()

digits : 55 non digits: 34

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

Bash, 2 chars

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

$0

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

share|improve this answer

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)

Forth

." Hello world!!!" \ 3141592653589793238462643383279502

Ruby

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
11  
Wow. This is so much different from my sh solution. –  ace Jan 18 at 16:08

http://esolangs.org/wiki/Hello%2B%2B

h000000000051090942171709440034

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 at 12:38

Your Answer

 
discard

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.