112
\$\begingroup\$

Your goal is to write a program that prints a number. The bigger the number, the more points you'll get. But be careful! Code length is both limited and heavily weighted in the scoring function. Your printed number will be divided by the cube of the number of bytes you used for your solution.

So, let's say you printed 10000000 and your code is 100 bytes long. Your final score will be 10000000 / 100^3 = 10.

There are other rules to follow, in order to make this challenge a bit harder.

  • You cannot use digits in your code (0123456789);
  • You can use mathematical/physical/etc. constants, but only if they are less than 10. (e.g. You can use Pi ~= 3.14 but you can't use the Avogadro constant = 6e23)
  • Recursion is allowed but the generated number needs to be finite (so infinite is not accepted as a solution. Your program needs to terminate correctly, assuming unbounded time and memory, and generate the requested output);
  • You cannot use the operations * (multiply), / (divide), ^ (power) nor any other way to indicate them (e.g. 2 div 2 is not allowed);
  • Your program can output more than one number, if you need it to do that. Only the highest one will count for scoring;
  • However, you can concatenate strings: this means that any sequence of adjacent digits will be considered as a single number;
  • Your code will be run as-is. This means that the end-user cannot edit any line of code, nor he can input a number or anything else;
  • Maximum code length is 100 bytes.

Leaderboard

  1. Steven H., Pyth ≈ fφ(1,0,0)+7(25626)/1000000[1]
  2. Simply Beautiful Art, Ruby ≈ fφ121(ω)(126)[1]
  3. Peter Taylor, GolfScript ≈ fε0+ω+1(17)/1000 [1]
  4. r.e.s., GolfScript ≈ fε0(fε0(fε0(fε0(fε0(fε0(fε0(fε0(fε0(126))))))))) [1]
  5. Simply Beautiful Art, Ruby ≈ fωω2+1(1983)
  6. eaglgenes101, Julia ≈ fω3(127)
  7. col6y, Python 3, ≈ (127→126→...→2→1) / 993 [1][3]
  8. Toeofdoom, Haskell,a20(1) / 993 [1]
  9. Fraxtil, dc, ≈ 15 ↑¹⁶⁶⁶⁶⁶⁵ 15 / 1003 [3]
  10. Magenta, Python, ≈ ack(126,126)/1003 ≈ 10 ↑124 129
  11. Kendall Frey, ECMAScript 6, ≈ 10 3 ↑4 3 / 1003 [1]
  12. Ilmari Karonen, GolfScript, ≈ 10 ↑3 10377 / 183 [1]
  13. BlackCap, Haskell, ≈ 10↑↑65503/1003
  14. recursive, Python, ≈ 2↑↑11 / 953 ≈ 10↑↑8.63297 [1][3]
  15. n.m., Haskell, ≈ 2↑↑7 / 1003 ≈ 10↑↑4.63297 [1]
  16. David Yaw, C, ≈ 10104×1022 / 833 ≈ 10↑↑4.11821 [2]
  17. primo, Perl, ≈ 10(12750684161!)5×227 / 1003 ≈ 10↑↑4.11369
  18. Art, C, ≈ 10102 × 106 / 983 ≈ 10↑↑3.80587
  19. Robert Sørlie, x86, ≈ 102219+32 / 1003 ≈ 10↑↑3.71585
  20. Tobia, APL, ≈ 1010353 / 1003 ≈ 10↑↑3.40616
  21. Darren Stone, C, ≈ 101097.61735 / 983 ≈ 10↑↑3.29875
  22. ecksemmess, C, ≈ 102320 / 1003 ≈ 10↑↑3.29749
  23. Adam Speight, vb.net, ≈ 105000×(264)4 / 1003 ≈ 10↑↑3.28039
  24. Joshua, bash, ≈ 101015 / 863 ≈ 10↑↑3.07282

Footnotes

  1. If every electron in the universe were a qubit, and every superposition thereof could be gainfully used to store information (which, as long as you don't actually need to know what's being stored is theoretically possible), this program requires more memory than could possibly exist, and therefore cannot be run - now, or at any conceiveable point in the future. If the author intended to print a value larger than ≈3↑↑3.28 all at once, this condition applies.
  2. This program requires more memory than currently exists, but not so much that it couldn't theoretically be stored on a meager number of qubits, and therefore a computer may one day exist which could run this program.
  3. All interpreters currently available issue a runtime error, or the program otherwise fails to execute as the author intended.
  4. Running this program will cause irreparable damage to your system.

Edit @primo: I've updated a portion of the scoreboard using a hopefully easier to compare notation, with decimals to denote the logarithmic distance to the next higher power. For example 10↑↑2.5 = 1010√10. I've also changed some scores if I believed to user's analysis to be faulty, feel free to dispute any of these.

Explanation of this notation:

If 0 ≤ b < 1, then a↑↑b = ab.

If b ≥ 1, then a↑↑b = aa↑↑(b-1).

If b < 0, then a↑↑b = loga(a↑↑(b+1)).

\$\endgroup\$
  • 15
    \$\begingroup\$ Has someone explicitly said "base 10" yet? \$\endgroup\$ – keshlam Jan 9 '14 at 14:42
  • 1
    \$\begingroup\$ Does the large number count if it's say 12e10 (12*10^10) as 12*10^10? \$\endgroup\$ – hichris123 Jan 9 '14 at 19:36
  • 4
    \$\begingroup\$ I think a better constraint instead of forbidding *, /, and ^, would've been to allow only linear operations, e.g. +, -, ++, --, +=, -=, etc. Otherwise, coders can take advantage of Knuth's up-arrow/Ackermann library functions if made available in their language of choice, which seems like cheating. \$\endgroup\$ – Andrew Cheong Jan 10 '14 at 0:19
  • 12
    \$\begingroup\$ I'm still waiting to see someone earn footnote [4]. \$\endgroup\$ – Brian Minton May 18 '17 at 15:41
  • 1
    \$\begingroup\$ Say, if my program prints 500b, is this invalid? That is, may we ignore all non-numeric things a program prints? And if so, would something like 50r7 count as 507? \$\endgroup\$ – Simply Beautiful Art May 22 '17 at 20:07

71 Answers 71

0
\$\begingroup\$

This is madness, to print the number it must be in the memory somehow, otherwise it would be considered as printing many separate numbers. I've written a JavaScript code and I've launched it in FireBug console. The largest result I've get with following code, on the quite strong workstation (8Core, 8GB RAM, haven't noted more details):

The code:

var e=Math.E,s=(e+'').replace('.',''),b=parseInt(s)
try{for(var i=e;i<b;i+=i)s+=s}catch(e){}
s

Code length: 94 characters (counted newlines as 1, you can replace them with semicolons and then it will be undoubtly 1). 94^3=830584. Test generated: '2718281828459045' repeated so many times, that the length of s was 1073741824 (over 1GB allocated). So the number is 2,7182*10^1073741824, and the points are:

3,27*10^1073741817

You can try to do that, but Firefox on my home laptop has crashed, so you need a really strong machine.

But many people has written the snipplets, noone has reported to be able to run! So let's remove that try.. catch and analyse what theoretically could happen:

The code:

var e=Math.E,s=(e+'').replace('.',''),b=parseInt(s);for(var i=e;i<b;i+=i)s+=s;s

Code length: 79 characters, 79^3=493039 The code will make 50 iterations generating the string of the length of 18014398509481984. Please verify if it would be able to store on 64 bit machine, but because the string is duplicated, there could be a theoretical machine able to compress such items in memory. However, I have no idea if there is enough energy in solar system to display the whole number on any console...

Anyway, we have number 2,7182*10^18014398509481984 divided by 79^3, so the poins are:

5,5*10^18014398509481977

Fill free to correct any mathematical errors, I've became a typical coding machine :D

\$\endgroup\$
  • \$\begingroup\$ In answer to your first statement: You can concatenate strings: this means that any sequence of adjacent digits will be considered as a single number; \$\endgroup\$ – Vereos Jan 10 '14 at 18:03
0
\$\begingroup\$

MATLAB ???/53^3

In matlab the maximum character size is defined and therefore this program will terminate eventually.

Basically it starts like this:

9
(9)!
((9)!)!
(((9)!)!)!    
...

I have no clue how big the number is but this will be allowed to grow to a string with approximately 2^41-1 elements (on windows 64 bit). Some help in estimating the resulting number size would be appreciated.

s=char('z'-'A')
while true
   s=['(' s ')!']
   vpa(s)
end
\$\endgroup\$
  • 1
    \$\begingroup\$ 1 is a digit, so is 2! \$\endgroup\$ – Vereos Jan 15 '14 at 10:02
  • \$\begingroup\$ @Vereos Edit: Thanks I did not even notice, have found a way around them! \$\endgroup\$ – Dennis Jaheruddin Jan 15 '14 at 10:12
  • \$\begingroup\$ This doesn't mean that those solutions are valid indeed. If you look at the leaderboard, you'll see that no solution in there has digits in it. EDIT: Alright :) \$\endgroup\$ – Vereos Jan 15 '14 at 10:12
  • \$\begingroup\$ The code at the bottom is an invalid program (non-terminating) and 9 is a digit. \$\endgroup\$ – Simply Beautiful Art Nov 12 '17 at 19:17
0
\$\begingroup\$

PHP (a lot)/83^3

Script should run for 99 seconds and produce as much 9's concatenated as it can.

$n=strlen("alphabeta");ini_set('max_execution_time',intval($n.$n));while($n)echo$n;
\$\endgroup\$
0
\$\begingroup\$

Squeak Smalltalk cheat: > 2^^(2^30) / 71^3 chars

^((Float pi at:Float e)to:(Float e at:Float e))reduceRight:[:x :y|x<<y]

Little explanation:

  • Internal bit representation of a Float can be accessed as a pair of 32 bit BigEndian words (a cheat)
  • #at: is tolerant and retries its parameter #asInteger (oh, not nice!)
  • << is left shift (a perfect cheat)
  • evaluate this expression via 'print it' menu, and the resulted number is printed in base 10

With characters left, I could also use significandAsInteger, but these are big enough yet. How big?

  • (Float pi at:Float e) -> 1413754136 > 2^31
  • (Float e at:Float e) -> 2333366121 > 2^31
  • ((Float pi at:Float e)to:(Float e at:Float e)) size -> 919611986>2^30

The first iteration is greater than 2^31*2^(2^31) > 2^^5
The second iteration is greater than 2^31*2^(2^^5) > 2^^6
...
The 2^30th iteration is greater than 2^^(2^30)

I let readers do the conversion to base 10, That kind of number gives me some vertigos...

Since this number is represented in memory, then converted to decimal by way of multiplications and divisions, let's say it's highly hypothetical...
Anyway, the technique consisting in storing the number in memory (base 2) then print, especially in Squeak is completely disqualified...
Creating a very small number is fast:
[1<<15000000] timeToRun -> 4 (milliseconds)
But LargeInteger package is not based on gmp and rapidly inefficient for base 10 conversion (naive * and /)
Even if I install a karatsuba multiplication, it takes quite long to print on my mac mini:
[1<<15000000 printOn: NullStream new] bench -> '2,700 seconds.'

A more reasonable loop in 32-bit memory:

What I can really execute is the first loop (let's omit the -1 on first term):

[((Float e at:Float e)<<(Float e at:Float e))] timeToRun -> 8732 (milliseconds)

As said above, I can 'do it' but I can't 'print it' in reasonable time with Squeak, though I can manipulate it, like having a guess of number of decimal digits:

((((Float e at:Float e)<<(Float e at:Float e)) highBit - 1) * 1233 >> 12) + 1-> 702402458, or log: 10 -> 10^(10^8.8)

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

C, undetermined (infinite?) output length / 62^3 67^3

l(){printf("%o",rand())-!!l&&l();}main(){srand(time(!l));l();}

l(){for(;printf("%o",rand())-!!l;l());}main(){srand(time(!l));l();}

I'd written this a few days prior, but was having a hard time figuring out the expected average length of the output. The program (given enough stack and time) eventually will terminate.

Was going to post when I figured the output length, but since Nate Eldridge's is similar, posting it now.

Originally had !'!' instead of !l; borrowed that part from Nate's answer.

I also had a similar version without srand, at 42 48 characters:

main(){printf("%o",rand())-!!'!'&&main();}

main(){for(;printf("%o",rand())-!!'!';main());}

Mine terminate (on average) earlier, compared to Nate's (10/RAND_MAX chance of popping up the stack instead of 1/RAND_MAX), but output more digits per iteration (~10.43 vs 1).

Edit: original actually terminated after RAND_MAX/20 iterations on average. Golfed too far.

Edit2: not enough rep to comment. Golfed Nate's entries below mine (64 and 44):

w(){for(printf("%o",w);rand();w());}main(){srand(time(!w));w();}

main(){for(printf("%o",'I');rand();main());}
\$\endgroup\$
0
\$\begingroup\$

TURKEY BOMB

PUDDING

Score - Infinitely large number (as large as your system will store) / 73


Similarly, this one will limit the size to the size of your computer, up to infinity and into unknowable values:

HYBRID OBTAINED BY COMBINING PUDDING & NOMENCLATURE [WITH GUSTO]
\$\endgroup\$
  • 1
    \$\begingroup\$ PUDDING is >10 \$\endgroup\$ – osvein Jan 16 '14 at 1:48
  • \$\begingroup\$ PUDDING is infinitely large. \$\endgroup\$ – Timtech Jan 16 '14 at 11:46
  • 1
    \$\begingroup\$ WTF did I just read? \$\endgroup\$ – George Reith Jan 20 '14 at 0:47
  • \$\begingroup\$ @GeorgeReith "an almanac of black magic of some sort, with the cryptic title "Communications of the ACM,"" \$\endgroup\$ – Timtech Jan 20 '14 at 0:51
  • \$\begingroup\$ This language is unimplemented and therefore not a valid answer per current site rules. \$\endgroup\$ – lirtosiast Dec 1 '18 at 1:59
0
\$\begingroup\$

Mathematica, 1.08544407066*10^23496 ≈ 10↑↑2.640580269

N[Cosh[Cosh[Cosh[Pi]]]]

It applies the hyperbolic cosine function to pi 3 times. If I had applied it 4 times, it would've caused an overflow error.

\$\endgroup\$
  • \$\begingroup\$ Overflow error should not be a problem here. \$\endgroup\$ – Simply Beautiful Art May 12 '17 at 11:53
  • \$\begingroup\$ N[Cosh[Cosh[Cosh[Cosh[Cosh[Cosh[Cosh[Cosh[Cosh[Cosh[Pi]]]]]]]]]]]. \$\endgroup\$ – user75200 Dec 28 '17 at 15:15
0
\$\begingroup\$

R, 63 characters of code, 4.036242e+3699695 ≈ 10↑↑2.81744412

set.seed(T)
paste(rep(RS<-abs(.Random.seed),RS[exp(T)]),collapse="")
# the result will be 3699696 digits long
# 624 repetitions of 4036241692704834420106146035583972223....

... or you can have it printing for as long as you have time:

set.seed(T)
repeat{cat(abs(.Random.seed),sep="")}
\$\endgroup\$
0
\$\begingroup\$

Lua, Unknown/99^3 ≈ 10↑↑2.945956159

With infinite runtime:

m=math;p=m.pi;t=m.floor(p)s=tostring;h=t+s(p):sub(t)j=h;while(j>t)do io.write(s(h):rep(h))j=j-t;end

< 5 seconds:

m=math;p=m.pi;t=m.ceil(p)s=tostring;h=t+s(p):sub(-t)j=h;while(j>t)do io.write(s(h):rep(h))j=j-t;end

Ungolfed:

t=math.ceil(math.pi)                -- Acquire the number 4
h=t+tostring(math.pi):sub(-t)       -- Get the last t(4) digits of pi(5898) as a string.
                                    -- Adding t auto converts it to a number and increases our number
j=h;                                -- Set j as a counter to loop
while(j>t)do
    io.write(tostring(h):rep(h))    -- Add h(5902) repitions of h as a string to the output
    j=j-t;                          -- Decrement j by t(4), my only number available
end

Extra

Lua's lack of mathematical constants (other than pi) and ++ or -- operators made it tricky to manipulate numbers, but I thought I made good work with what I have. string.rep is the real hero.

If there's a notation that exists to write my score, I'll include it, but I don't know of one. If I was thinking correctly, the < 5 code's number should be (5902 repeated 5902 times) repeated ~5902/4 times.

\$\endgroup\$
  • \$\begingroup\$ Hello! What does this program do? \$\endgroup\$ – NoOneIsHere May 10 '16 at 23:26
  • \$\begingroup\$ @NoOneIsHere Added ungolfed code with explanation. That should help. \$\endgroup\$ – Blab May 11 '16 at 0:51
  • \$\begingroup\$ If your last line is correct, your number should be ≈10^174,000,000 \$\endgroup\$ – Simply Beautiful Art May 13 '17 at 21:31
0
\$\begingroup\$

Javascript, > 10316469 ≈ 10↑↑2.740388839

(Run from the browser console to get output)

for(a="",b="■".charCodeAt``;b--;)a+=(''+b).repeat("■".charCodeAt``);a
\$\endgroup\$
0
\$\begingroup\$

Python2

o=oct(ord('~'))
for a in range(int(o)):
    o+=o*int(o)
    for b in range(int(o)):
        o+=o*int(o)
o*int(o)

This is exactly 100 characters if the indentations are tabs.

In order for the program to output, it needs to be run in a python console rather than in a file.

Score is unknown at this point because the inner for loop will run 10e707 times in the first iteration of the outer loop. and in total, there will be 176 iterations of the outer loop. Also, this output is too big for me to even comprehend how to mark the notation for it.

\$\endgroup\$
  • 1
    \$\begingroup\$ Unnecessary spacing removed, there may be integer multiplication involved, there is nothing printed unless that's what the last line does, and the value of o*int(o) at the end should be approximately 10↑↑↑↑176. \$\endgroup\$ – Simply Beautiful Art May 18 at 19:30
  • \$\begingroup\$ For a small optimization, the third line should be moved up so that the outer loop runs more times. \$\endgroup\$ – Simply Beautiful Art May 18 at 19:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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