22
\$\begingroup\$
  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.

\$\endgroup\$
17
  • 7
    \$\begingroup\$ Thus, all solutions have a character count which is a fibonacci number. \$\endgroup\$
    – Howard
    Jan 18, 2014 at 9:02
  • 1
    \$\begingroup\$ Here is a program to validate answers (paste the code into the input box.) \$\endgroup\$
    – Justin
    Jan 18, 2014 at 9:19
  • 1
    \$\begingroup\$ 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. \$\endgroup\$
    – Justin
    Jan 18, 2014 at 9:24
  • 2
    \$\begingroup\$ @Plarsen definitely not OK \$\endgroup\$ Jan 18, 2014 at 9:37
  • 1
    \$\begingroup\$ Okay, I will not change the rules then :) \$\endgroup\$ Jan 18, 2014 at 9:38

24 Answers 24

23
\$\begingroup\$

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
\$\endgroup\$
6
  • 3
    \$\begingroup\$ Wow! I think we had got a winner if the rules wasn't saying no input. +1 anyway for the outside-of-box thinking. \$\endgroup\$ Jan 18, 2014 at 12:37
  • 2
    \$\begingroup\$ Code golf with Windows CMD... +1. Also, it is arguable that "no input" could have meant "no reading STDIN" :P \$\endgroup\$ Jan 19, 2014 at 5:06
  • 1
    \$\begingroup\$ 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> \$\endgroup\$
    – Tobia
    Jan 19, 2014 at 18:36
  • 1
    \$\begingroup\$ That's impossible!! 5 chars? Really interesting approach \$\endgroup\$ Jan 20, 2014 at 11:46
  • 1
    \$\begingroup\$ In fact, I've just posted a 2 char solution below. \$\endgroup\$
    – Tobia
    Jan 20, 2014 at 13:32
21
\$\begingroup\$

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)
\$\endgroup\$
3
  • 5
    \$\begingroup\$ What the... CMD and SQL winning code golf?? \$\endgroup\$ Jan 19, 2014 at 5:08
  • \$\begingroup\$ The select and ; are arguably part of the statement, but still a clever solution. \$\endgroup\$
    – primo
    Jan 21, 2014 at 5:57
  • \$\begingroup\$ @primo they are, that's why I'm unsure whether this qualifies. But I thought I'd post it for hilarity ;-) \$\endgroup\$
    – Tobia
    Jan 21, 2014 at 9:35
16
\$\begingroup\$

C64 BASIC, 55

enter image description here

For fun and nostalgia!

\$\endgroup\$
11
\$\begingroup\$

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.

\$\endgroup\$
0
10
\$\begingroup\$

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.

\$\endgroup\$
8
\$\begingroup\$

Python 34-55

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

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

\$\endgroup\$
3
  • \$\begingroup\$ Who knew pi~3 would be so useful! \$\endgroup\$
    – Kyle Kanos
    Jan 18, 2014 at 15:52
  • 1
    \$\begingroup\$ The question says 21 non-numeric plus 34 numeric, your answer is 34 non-numeric plus 21 numeric. \$\endgroup\$
    – user12205
    Jan 18, 2014 at 15:55
  • 1
    \$\begingroup\$ the "hello world" should be "Hello world"; that is capitalize the h. \$\endgroup\$
    – Justin
    Jan 18, 2014 at 18:04
7
\$\begingroup\$

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.

\$\endgroup\$
4
  • \$\begingroup\$ You know you can edit the bit.ly links right? \$\endgroup\$
    – Timtech
    Jan 18, 2014 at 15:03
  • \$\begingroup\$ What do you mean, edit? Also, I wouldn't get this under 13 letters in any case. \$\endgroup\$ Jan 18, 2014 at 15:05
  • \$\begingroup\$ You can hit the pencil next to "Copy" and edit the link. If you do, all the old versions will still work. \$\endgroup\$
    – Timtech
    Jan 18, 2014 at 22:18
  • 1
    \$\begingroup\$ Shortened to 34! curl 37.187.42.18/?hw=112358132134 \$\endgroup\$ Jan 19, 2014 at 8:55
7
\$\begingroup\$

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});}
\$\endgroup\$
5
  • \$\begingroup\$ 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! \$\endgroup\$ Jan 20, 2014 at 1:51
  • \$\begingroup\$ 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. \$\endgroup\$
    – ugoren
    Jan 20, 2014 at 13:20
  • \$\begingroup\$ 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? \$\endgroup\$
    – vmrob
    Jan 20, 2014 at 19:55
  • \$\begingroup\$ @vmrob, globals have to have a declaration. But the type defaults to int, so a; is equivalent to int a;. \$\endgroup\$
    – ugoren
    Jan 21, 2014 at 20:40
  • \$\begingroup\$ @ugoren I knew that they had to have a declaration, I just didn't realize it defaulted to int! \$\endgroup\$
    – vmrob
    Jan 21, 2014 at 20:42
6
\$\begingroup\$

sh, 55

echo Hello world!!! #1234567890123456789012345678901234
\$\endgroup\$
6
\$\begingroup\$

Korn Shell, 21

echo $0
#123456789012

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

\$\endgroup\$
5
\$\begingroup\$

Python

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

digits : 55 non digits: 34

\$\endgroup\$
1
  • \$\begingroup\$ Note there are no comments in the solution. only code. \$\endgroup\$
    – Elisha
    Jan 21, 2014 at 21:48
4
\$\begingroup\$

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
\$\endgroup\$
1
  • \$\begingroup\$ @JanDvorak: I'm almost sure I read "before or after". Oh well, let me fix it then. \$\endgroup\$
    – 0..
    Jan 18, 2014 at 10:38
4
\$\begingroup\$

Mathematica 55

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

Output

Hello World!!!
\$\endgroup\$
4
\$\begingroup\$

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

\$\endgroup\$
4
\$\begingroup\$

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.

\$\endgroup\$
2
3
\$\begingroup\$

Vyxal , 8+13=21 bytes

kh6⁽NV33C3ẋ#123456789

kh6⁽NV = Hello world

33C = ASCII 33 to !

3ẋ = repeat top of stack three times

(Note that 33C3ẋ is one non numeric less than literal !!! would be)

Try it Online!

\$\endgroup\$
1
  • \$\begingroup\$ Yeah unfortunately I can’t seem to get the string with only 5 non-numeric chars \$\endgroup\$
    – noodle man
    Sep 24, 2023 at 21:44
2
\$\begingroup\$

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.

\$\endgroup\$
2
\$\begingroup\$

J (55 characters)

(34 numeric + 21 non-numeric)

(72 101 108 108 111 32 119 111 114 108 100{a.), 3#33{a.
\$\endgroup\$
1
\$\begingroup\$

APL, 55 bytes

14↑'Hello world!!!!!!!11111111111111111111111111111111'
\$\endgroup\$
0
\$\begingroup\$

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!!!
\$\endgroup\$
0
\$\begingroup\$

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.

\$\endgroup\$
0
\$\begingroup\$

Pxem, Numeric: 34 bytes + Non-numeric: 21 bytes = 55 bytes.

  • Filename: Hello world!!!.pxxxxx1234567890123456789012345678901234
  • Content: empty

The boring answer. The stupid latter part is nothing but a garbage.

Try it online!

\$\endgroup\$
0
\$\begingroup\$

Python 3.11, 34+21=55 bytes

Boring answer, uses comments to store extra junk.

print("Hello world!!!")#abcdef12345678901234567890123456
\$\endgroup\$
-1
\$\begingroup\$

Windows Batch

echo Hello World!!!::0123456789012345678901234567890123
\$\endgroup\$
1
  • 13
    \$\begingroup\$ Wow. This is so much different from my sh solution. \$\endgroup\$
    – user12205
    Jan 18, 2014 at 16:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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