Shortest code for longest output

Python: 8 chars code, 387420489 chars output -- Ratio: 48427561.125 : 1

'a'*9**9

We can have the ratio tend to infinity by adding more **9s:

'a'*9**9**9
'a'*9**9**9**9
etc.

For example:

'a'*9**9**9**9**9**9

which has a ratio of ~10101010108.568 (unimaginably large number).


So, these are all good programs that produce lots of output with very little code, but none of them are really short...

brainfuck, 5 characters, 255 bytes of output

-[.-]

I think this is the only use case where brainfuck really excels. I know this one isn't going to win, but I don't think we can possibly do better than the Python example. Not only that, but...

brainfuck, 4 characters, infinite output

-[.]

I conjecture that this is the shortest infinite-output program out there.

Actually, hold on, my mate's just come up with a really good one.

Python, 80 bytes, unknown amount of output

from datetime import datetime
while datetime.now()!=datetime.max()
 print "This will probably get disqualified"

This program will definitely halt eventually, but will only do so after roughly 8,000 years. The exact number of characters output depends on the rate at which your computer can produce characters.


Perl - 19 bytes, 187200000000000000 bytes output (9852631578947368.42 : 1)

print+($]x9e7)x26e7

166 petabyes with a single print statement, using no more than 1.7GB of memory.

There's a few things that made this challenge more interesting that I thought it would be. Perl seems to refuse to allocate more than 1GB of memory to any single list. Hence, the 4-byte scalar reference to the inner string may only be repeated 26e7 ≈ 228 times. $] is the 'old perl version' number which, as a string, is 8 bytes long, resembling 5.016002.

With more system memory, it should be able to go higher. Assuming the full 8GB were actually available, you should be able to use $]x9e8 for the inner string instead, which would output 1.62 exabytes.

Tags:

Code Golf