Hello world!!! Fibonacci distribution

21

1

  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.

Plarsen

Posted 2014-01-18T08:54:51.943

Reputation: 1 740

6Thus, all solutions have a character count which is a fibonacci number. – Howard – 2014-01-18T09:02:16.283

@Howard Indeed. This is a very interesting problem. – cjfaure – 2014-01-18T09:11:04.903

1Here is a program to validate answers (paste the code into the input box.) – Justin – 2014-01-18T09:19:39.577

1Is 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 – 2014-01-18T09:24:56.243

I regret I didn't put a constraint on the distribution for the non-numeric too, separating alpha-characters and symbols. Is it okay to update the rules now this late, rendering your answers invalid? – Plarsen – 2014-01-18T09:35:16.410

2@Plarsen definitely not OK – John Dvorak – 2014-01-18T09:37:27.607

1Okay, I will not change the rules then :) – Plarsen – 2014-01-18T09:38:37.330

@Quincunx: It is possible. – Konrad Borowski – 2014-01-18T10:13:29.010

@xfix it might be, but your solution doesn't achieve that – John Dvorak – 2014-01-18T10:39:29.313

Questions without an objective primary winning criterion are off-topic, as they make it impossible to indisputably decide which entry should win. A codegolf challenge where the code length is forced to be a certain value lack such a criterion. – John Dvorak – 2014-01-18T10:46:54.620

I added a criterion for who will win if more than one answer shares the same character count. – Plarsen – 2014-01-18T10:53:43.510

@Plarsen Why don't you change it and say: "write the smallest program you can" and change [tag:code-golf] to [tag:popularity-contest]? – Justin – 2014-01-18T17:55:55.107

What would have been even more interesting would be to specify that all characters had to be functional - that is, comments and non-essential code could not contribute to the character count. – Iszi – 2014-01-19T06:52:19.213

I agree, @Iszi. I threw answers in, in two languages because padding with comments made it easy. However, while "no comments" could be construed as objective criteria, I think "non-essential code" could be seen as subjective. (It's usually easy to weave some numeric calculation or string manipulation into code which does something and, if cleverly woven, cannot be removed without fundamentally rewriting the answer.) – Darren Stone – 2014-01-20T21:58:18.987

Answers

27

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

Robert Sørlie

Posted 2014-01-18T08:54:51.943

Reputation: 1 036

2Wow! I think we had got a winner if the rules wasn't saying no input. +1 anyway for the outside-of-box thinking. – Plarsen – 2014-01-18T12:37:46.507

2Code golf with Windows CMD... +1. Also, it is arguable that "no input" could have meant "no reading STDIN" :P – Camilo Martin – 2014-01-19T05:06:23.547

1That'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 – 2014-01-19T18:36:22.660

1That's impossible!! 5 chars? Really interesting approach – Plarsen – 2014-01-20T11:46:34.777

1In fact, I've just posted a 2 char solution below. – Tobia – 2014-01-20T13:32:33.167

20

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)

Tobia

Posted 2014-01-18T08:54:51.943

Reputation: 5 455

5What the... CMD and SQL winning code golf?? – Camilo Martin – 2014-01-19T05:08:24.210

The select and ; are arguably part of the statement, but still a clever solution. – primo – 2014-01-21T05:57:01.807

@primo they are, that's why I'm unsure whether this qualifies. But I thought I'd post it for hilarity ;-) – Tobia – 2014-01-21T09:35:01.027

16

C64 BASIC, 55

enter image description here

For fun and nostalgia!

Gabriele D'Antona

Posted 2014-01-18T08:54:51.943

Reputation: 1 336

11

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.

Howard

Posted 2014-01-18T08:54:51.943

Reputation: 23 109

10

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.

Justin

Posted 2014-01-18T08:54:51.943

Reputation: 19 757

8

Python 34-55

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

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

Reut Sharabani

Posted 2014-01-18T08:54:51.943

Reputation: 208

Who knew pi~3 would be so useful! – Kyle Kanos – 2014-01-18T15:52:44.083

1The question says 21 non-numeric plus 34 numeric, your answer is 34 non-numeric plus 21 numeric. – user12205 – 2014-01-18T15:55:01.720

1the "hello world" should be "Hello world"; that is capitalize the h. – Justin – 2014-01-18T18:04:13.070

7

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});}

vmrob

Posted 2014-01-18T08:54:51.943

Reputation: 181

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 – 2014-01-20T01:51:08.680

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 – 2014-01-20T13:20:51.390

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 – 2014-01-20T19:55:23.870

@vmrob, globals have to have a declaration. But the type defaults to int, so a; is equivalent to int a;. – ugoren – 2014-01-21T20:40:42.463

@ugoren I knew that they had to have a declaration, I just didn't realize it defaulted to int! – vmrob – 2014-01-21T20:42:30.243

6

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.

John Dvorak

Posted 2014-01-18T08:54:51.943

Reputation: 9 048

You know you can edit the bit.ly links right? – Timtech – 2014-01-18T15:03:54.740

What do you mean, edit? Also, I wouldn't get this under 13 letters in any case. – John Dvorak – 2014-01-18T15:05:41.823

You can hit the pencil next to "Copy" and edit the link. If you do, all the old versions will still work. – Timtech – 2014-01-18T22:18:04.813

1Shortened to 34! curl 37.187.42.18/?hw=112358132134 – Dom Hastings – 2014-01-19T08:55:32.330

6

sh, 55

echo Hello world!!! #1234567890123456789012345678901234

user12205

Posted 2014-01-18T08:54:51.943

Reputation: 8 752

6

Korn Shell, 21

echo $0
#123456789012

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

Gabriele D'Antona

Posted 2014-01-18T08:54:51.943

Reputation: 1 336

5

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.

Tobia

Posted 2014-01-18T08:54:51.943

Reputation: 5 455

5

Python

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

digits : 55 non digits: 34

Elisha

Posted 2014-01-18T08:54:51.943

Reputation: 1 015

Note there are no comments in the solution. only code. – Elisha – 2014-01-21T21:48:13.113

4

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

Konrad Borowski

Posted 2014-01-18T08:54:51.943

Reputation: 11 185

@JanDvorak: I'm almost sure I read "before or after". Oh well, let me fix it then. – Konrad Borowski – 2014-01-18T10:38:55.280

4

Mathematica 55

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

Output

Hello World!!!

ybeltukov

Posted 2014-01-18T08:54:51.943

Reputation: 1 841

4

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 :(

Timwi

Posted 2014-01-18T08:54:51.943

Reputation: 12 158

2

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.

Darren Stone

Posted 2014-01-18T08:54:51.943

Reputation: 5 072

2

J (55 characters)

(34 numeric + 21 non-numeric)

(72 101 108 108 111 32 119 111 114 108 100{a.), 3#33{a.

Mort Yao

Posted 2014-01-18T08:54:51.943

Reputation: 121

0

Japt, 55 bytes

"aaaaaaa1234567890123456789012345678901234"`HÁM WŽld!!!

Try it online!

It is basically a simple hello world with some rubbish at the beginning that is ignored but makes the code satisfy the conditions.

Hawkings

Posted 2014-01-18T08:54:51.943

Reputation: 191

0

C#, 233 Bytes

233 Characters
144 Numeric
89 Non-Numeric Characters

/*I suck at CodeGolf!!!*/new List<int>{0072,00101,000108,000108,000111,0000032,00000119,00000111,0000000000114,0000000000108,00000000000000100,00000000000000033,00000000000000033,00000000000000033}.ForEach(c=>Console.Write((char)c));

Outputs:

Hello world!!!

Pete Arden

Posted 2014-01-18T08:54:51.943

Reputation: 1 151

-1

Windows Batch

echo Hello World!!!::0123456789012345678901234567890123

Timtech

Posted 2014-01-18T08:54:51.943

Reputation: 12 038

12Wow. This is so much different from my sh solution. – user12205 – 2014-01-18T16:08:46.020

-3

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

h000000000051090942171709440034

the h prints hello and the rest is just numbers

qwerty

Posted 2014-01-18T08:54:51.943

Reputation: 11

This is not distributed according to Fibonacci, also, the output is not exactly Hello world!!! – Timtech – 2014-01-23T12:38:40.090