Output a googol copies of a string

64

3

I am interested in seeing programs which don't ask for any input, print a googol copies of some nonempty string, no less, no more, and then stop. A googol is defined as 10^100, i.e., 1 followed by a hundred 0's in decimal.

Example output:

111111111111111111111111111111111111111111111111111111111111111111111111...

or

Hello world
Hello world
Hello world
Hello world
Hello world
Hello world
...

The string can also be entirely composed of white space or special symbols. The only exception to identical copies of a fixed string is if your language decorates the output in some way that can not be prevented, but could be trivially undone in a wrapper script, like prepending a line number to each line. The wrapper script in such cases need not be provided.

You can assume your computer will never run out of time, but other than that, your program must have a reasonable demand of resources. Also, you must respect any restrictions that the programming language of your choice poses, for example, you can not exceed a maximum value allowed for its integer types, and at no point more than 4 GB of memory must be needed.

In other words, the program should in principle be testable by running it on your computer. But because of the extent of this number you will be expected to prove that the number of copies of the string it outputs is exactly 10^100 and that the program stops afterwards. Stopping can be exiting or halting or even terminating due to an error, but if so, the error must not produce any output that could not easily be separated from the program's output.

This is , so the solution with the fewest bytes wins.

Example solution (C, ungolfed, 3768 bytes)

#include <stdio.h>

int main() {
  int a00, a01, a02, a03, ..., a99;
  for(a00 = 0; a00 < 10; a00++)
  for(a01 = 0; a01 < 10; a01++)
  for(a02 = 0; a02 < 10; a02++)
  for(a03 = 0; a03 < 10; a03++)
  ...
  for(a99 = 0; a99 < 10; a99++)
    puts("1");
  return 0;
}

The Vee

Posted 2016-10-29T18:41:41.303

Reputation: 771

First question here. Improvements, style/tag corrections, comments etc. welcome. Have fun! – The Vee – 2016-10-29T18:42:41.660

10

Consider the sandbox first next time.

– cat – 2016-10-29T18:44:39.897

@cat Sorry, I don't understand what that link is about. CW is community wiki, right? How is that related? – The Vee – 2016-10-29T18:46:50.647

9

When you post a new question, you are asked to first post it in the sandbox.

– flawr – 2016-10-29T18:48:16.150

@flawr Should I delete this and repost there? – The Vee – 2016-10-29T18:49:16.950

@flawr I'm afraid someone may already be working on it. I'm sorry, somehow the line slipped my attention :-( – The Vee – 2016-10-29T18:59:56.373

Next, somebody should create a challenge needing to output a ---Google Plex---googleplex copies of a string – user41805 – 2016-10-29T19:14:32.847

1@KritixiLithos It was toying with that idea but I could not quickly come up with a sample solution. Feel free to make a sequel :-) – The Vee – 2016-10-29T19:16:15.660

Does it have to be separate print statements? Or can we do something like print's'*(10**100)? – Rɪᴋᴇʀ – 2016-10-29T21:48:05.743

@EasterlyIrk You did not specify language but if this generically means creating a string 10^100 characters long and then printing it then that's what the "realistic computer" and memory restriction are meant to be against. The 4 GB is just an arbitrary number but this would require something far beyond all SI prefixes. – The Vee – 2016-10-29T21:55:51.093

Unfortunately I can't judge whether that happens in the programs written in languages I don't understand, but I hope that's what the community will detect. This happened in some of the answers, I'm not going to cite because the respective authors decided to hide their comment discussion. – The Vee – 2016-10-29T21:58:18.397

But if your language uses lazy stream creation and printing, sure, go for it. Or if this means "repeat print's' 10^100 times". – The Vee – 2016-10-29T21:59:02.417

3@closevoter Are you sure this is too broad? Common sense automatically narrows this down from "print a nonempty string 10^100 times" to "print a character 10^100 times". – user8397947 – 2016-10-29T23:47:23.897

You can separate error output with 2>nul or 2>/dev/null, depending on your OS :) – Erik the Outgolfer – 2016-10-30T10:22:01.903

@KritixiLithos *Googolplex – Oliver Ni – 2016-10-30T16:57:07.333

@Oliver I can't stop thinking about Google that it has entered my subconsciousness :D – user41805 – 2016-10-30T16:59:41.983

3TIL Googol-1 in Roman numerals – mbomb007 – 2016-10-31T18:36:01.290

"at no point no more than 4 GB of memory must be needed" means that more than 4GB of memory must be needed at all times – user253751 – 2016-10-31T23:39:45.170

Can I write main=putStr$cycle"x", which prints s a googol times, where s is the infinite string with all characters x? – wchargin – 2016-11-01T00:06:22.600

@wchargin Nice try :-) But your program would print just a single copy of s. The ordinal ω . 10^100 that you would need there is clearly distinctive from ω. – The Vee – 2016-11-02T10:45:56.287

Are we allowed to use the system time? Something like making one output a second, and then terminating the program when the time 1 googol seconds after the current system time is reached. – ghosts_in_the_code – 2017-01-16T10:17:52.173

Answers

35

Jelly, 6 4 bytes

³Ȯ*¡

This is a niladic link (function w/o arguments) that prints 10200 copies of the string 100, meaning that it prints 10100 copies of the string that consists of 10100 copies of the string 100.

Try it online!

Note that the online interpreter cuts the output at 100 KB for practical reasons. The code also works as a full program, but due to implicit output, that program prints one copy too many.

How it works

³Ȯ*¡  Niladic link. No arguments.

³     Set the left argument and initial return value to 100.
 Ȯ    Print the current return value.
  *   Compute 100 ** 100 = 1e200.
   ¡  Call Ȯ 1e200 times. 

Dennis

Posted 2016-10-29T18:41:41.303

Reputation: 196 637

3Well... Wow... Printing 10^100 copies of the original output (10^100 copies of a string) is taking it a little far, even for two whole bytes. Have you submitted this to the "score is output / program-length, highest wins" challenge yet? – wizzwizz4 – 2016-10-31T17:30:26.017

1Not sure which challenge you're referring to (we had a few of this type), but 3e200 probably isn't competitive anyway. – Dennis – 2016-10-31T18:26:12.090

2@wizzwizz4 If you can express your number in standard notation it's probably waaay too small. – orlp – 2016-10-31T21:46:16.847

Truly fascinating language and answer. I think no one is going to beat 4 bytes!! :-D Thanks for all your active participation in spotting programs which would not pass the rules, too! – The Vee – 2016-10-31T23:49:20.913

Does this actually work? I would think it would fall over on 100 ** 100 – Loren Pechtel – 2016-11-01T00:13:22.847

@LorenPechtel I'm not sure I understand. What do you mean by fall over? – Dennis – 2016-11-01T00:55:28.103

1"Fall over" = fail/crash – Loren Pechtel – 2016-11-01T03:25:41.553

@LorenPechtel I see no reasons why it would. This is a simple for loop, so memory holds nothing more than the integer 100, a counter, the 665-bit limit, and the interpreter itself. Of course it will never finish printing the 3e200 characters it is supposed to, but that's something all valid answers to this challenge have in common... – Dennis – 2016-11-01T03:32:47.043

Unless you have unlimited length integers your 100 ** 100 is going to be a problem. – Loren Pechtel – 2016-11-01T03:43:07.260

4@LorenPechtel Jelly is implemented in Python, which handles 665-bit integers with ease. – Dennis – 2016-11-01T03:44:11.397

@LorenPechtel If the upper bound was a problem, the program would fail before entering the for loop, as you observed. But one can easily check that this does not happen in the online evaluator. – The Vee – 2016-11-01T12:08:34.083

I think this actually prints 10²⁰⁰+1 copies of 100. I have tested it with 2Ȯ*¡, and, while it should have printed 2²=4 2s, it printed five instead (22222 instead of 2222), because Ȯ returns z. Something similar would happen to 100 too, given enough time and memory etc. I think that makes it invalid. However, I have found a simple 6-byte solution that is valid: ³Ȯ*¡ṛ“. ṛ“ solves the exact problem I've described, it replaces the value returned by Ȯ (100) by the empty string ([]). – Erik the Outgolfer – 2016-12-26T23:13:29.490

@EriktjeOutgolfer This is a function submission. As I said in my answer, the code also works as a full program, but due to implicit output, that program prints one copy too many.. – Dennis – 2016-12-26T23:29:04.993

@Dennis You typo'd my name, so I didn't see your reply. What I think though is that OP asked for a program. They mention being interested in programs, but no reference to functions. – Erik the Outgolfer – 2016-12-28T10:35:31.830

@EriktheOutgolfer Whoops, sorry for the botched ping. On PPCG, program means full program or function.

– Dennis – 2016-12-28T15:03:00.093

@Dennis TBH I haven't seen that post in the past. Even though it's not the most popular answer, it is the most popular answer which defines "program". I couldn't have imagined such a thing... – Erik the Outgolfer – 2016-12-28T15:11:34.220

@EriktheOutgolfer it's just a default. questions are welcome to specify "no functions", but it has to be made explicit. – Sparr – 2017-01-23T22:25:22.833

I don't think I could beat this in any of the languages I know. – ckjbgames – 2017-01-23T22:26:02.117

@ckjbgames the languages designed for golfing generally aren't beatable by normal languages. that doesn't mean those normal languages aren't worth using. it's common here to encourage at least one answer in each language. we usually don't compare python answers to pyth answers, just to each other. – Sparr – 2017-01-23T22:29:04.783

60

Fuzzy Octo Guacamole, 13 12 11 10 bytes

9+ddpp![g] 

Explanation:

9+ddpp![g]
9+           # push 9 and increment, giving 10
  dd         # duplicate, twice. now you have [10,10,10]
    pp       # raise a 10 to the 10th power, then raise that to the 10th again. That ends up being 10^100.
      ![ ]   # for loop, `!` sets the counter to the top of stack
        g    # prints an ASCII art goat. 

Sample of the goat printed:

                  ___.
                 //  \\
                ((   ""
                 \\__,
                /6 (%)\,
               (__/:";,;\--____----_
                ;; :";,:";`;,";,;";`,`_
                  ;:,;;";";,;":,";";,-Y\
                   ;,;,;";";,;":;";"; Z/
                   / ;,";";,;";,;";;"
                  / / |";/~~~~~\";;"
                 ( K  | |      || |
                  \_\ | |      || |
                   \Z | |      || |
                      L_|      LL_|
                      LW/      LLW/

Rɪᴋᴇʀ

Posted 2016-10-29T18:41:41.303

Reputation: 7 410

2It took me a while to understand the head of the goat. It's not easily recognizable. – mbomb007 – 2016-10-31T17:14:07.723

The gaot gave me the ASCII art, ask him about it. – Rɪᴋᴇʀ – 2016-10-31T17:14:54.387

9I have no idea what you are talking about. +1. – djechlin – 2016-10-31T21:56:56.170

15@djechlin Downgoat asked me to add a builtin for printing a goat. I obliged. – Rɪᴋᴇʀ – 2016-11-01T00:24:27.317

21

Python, 28 bytes

-1 byte thanks to Jonathan Allan!

Python 2:

i=10**100
while i:print;i-=1

Python 3 (30 bytes):

i=10**100
while i:print();i-=1

FlipTack

Posted 2016-10-29T18:41:41.303

Reputation: 13 242

2i=10**100 newline while i:print();i-=1 saves a byte. Save two more by using Python 2 with while i:print;i-=1 – Jonathan Allan – 2016-10-29T19:40:46.590

@JonathanAllan thanks for the -1 byte. As for the Python 2 solution, I'll leave that for you to post :) – FlipTack – 2016-10-29T19:55:40.357

Nice first answer! :) – Daniel – 2016-10-30T14:27:43.130

Can Python actually store 10 to the 100 in an integer? – Arturo Torres Sánchez – 2016-10-31T06:42:16.017

7@ArturoTorresSánchez yep, there's no upper limit on int size in python :) – FlipTack – 2016-10-31T06:47:50.023

@JohnLeuenhagen It doesn't need 4GB... According to wikipedia, you need 333 bits. The python function sys.getsizeof() tells me that it's 58 bytes. Either way, that's nowhere near the limit this challenge specifies, and it runs fine on my laptop.

– FlipTack – 2016-11-01T19:50:25.360

I'm not well versed in dynamically typed languages, but could you save two bytes by going like so: while i<10**100:print();i+=1 ? – tuskiomi – 2016-12-12T20:45:51.373

@tuskiomi well, I'd still need to define i=0 at the top, which would end up costing 2 more bytes. – FlipTack – 2016-12-12T20:54:50.223

i cannot be defined implicitly as null? – tuskiomi – 2016-12-12T20:55:39.563

@tuskiomi nope, i has to have a value before it can be used – FlipTack – 2016-12-12T20:58:40.843

You could save several bytes by not assigning a variable and fitting it all on one line, like this: while 10**100:print();i-=1 – ckjbgames – 2017-01-23T22:36:09.453

@ckjbgames No I couldn't, because while 10**100 will always evaluate to true, and i-=1 would throw a NameError as we haven't defined i. – FlipTack – 2017-01-23T22:37:18.220

@FlipTack Also didn't consider that. I put it through a byte counter and found the same. I don't know if it can be golfed any more than the Python 2 version. – ckjbgames – 2017-01-23T22:52:32.283

18

Haskell, 28 bytes

main=putStr$[1..10^100]>>"1"

Concatenates 10^100 copies of the string "1" and prints it.

nimi

Posted 2016-10-29T18:41:41.303

Reputation: 34 639

Is the string concatenation done before the printing starts? If so I would think this breaks the rule about "no more than 4 GB of memory"... – daniero – 2016-10-30T12:39:59.853

8@daniero: thanks to Haskell's laziness printing starts immediately. On my computer the program needs less than 2MB memory (including the run time system RTS). – nimi – 2016-10-30T16:17:18.630

Is s=[1..10^100]>>"1" an allowed answer format? – user253751 – 2016-10-31T23:46:39.870

Infinite integers? Otherwise it falls over on 10^100 – Loren Pechtel – 2016-11-01T00:15:44.490

@immibis: the challenge says "print", which usually means "print to stdout". s from your example doesn't print - or if you use the REPL surrounds the 1 with ". I guess just putStr$[1..10^100]>>"1" without the main= would be fine, but I wanted to submit a full program. – nimi – 2016-11-01T00:20:19.967

@LorenPechtel: not "infinite", but arbitrary large. Type 10^100 in the online repl at the home page of www.haskell.org and it happily prints the result.

– nimi – 2016-11-01T00:24:42.787

17

Brainfuck, 480 188 114 106 98 bytes

Just because it needs to be done.

Assumes 8-bit cells with wrapping. Prints 250255 NUL bytes, which is 10100 times 10155 times 25255 NUL bytes.

>>>>>>-[[->>>+<<<]------>>>-]<<<[<<<]+[+[>>>]<<<->+[<[+>-]>[-<<<<->+>>------>>]<<<<]>>-[<<<].>>>-]

Explanation:

>>>>>> is needed to leave a bit of working space.

- produces 255.

[[->>>+<<<]------>>>-] turns this into 255 copies of the value 250, giving a tape that looks like:

0 0 0 0 0 0 250 0 0 250 0 0 ... 250 0 0 [0]

<<<[<<<]+ moves the data pointer back and finishes up the initial data:

0 0 0 [1] 0 0 250 0 0 250 0 0 ...

Then comes the loop: [+...-] initially sets the 1 to a 2, which gets set back to 1 at the end of the loop. The loop terminates when the loop body already set 2 to 1.

Now, the numbers 2 250 250 250 ... 250 represent a counter, in base 250, with each number one greater than the digit it represents.

  • [>>>]<<< moves all the way to the right. Since each digit is represented by a non-zero number, this is trivial.

  • ->+[<[+>-]>[-<<<<->+>>------>>]<<<<]>>- decreases the counter by 1. Starting with the last digit: the digit gets decremented. If it remains positive, we're done. If it turns to zero, set it to 250, and continue with the digit before.

  • [<<<].>>> moves the pointer back before the left-most digit, and this is a nice moment to print a NUL byte. Then re-position to exactly the left-most digit, to see if we're done.

To verify correctness, change the initial - to + to print 2501 NUL bytes, ++ for 2502, etc.

hvd

Posted 2016-10-29T18:41:41.303

Reputation: 3 664

16

C, 51 bytes

Function g() calls recursive function f() to depth 99.

Excludes unnecessary newline added between f() and g() for clarity.

f(n,i){for(i=10;i--;)n?f(n-1):puts("");}
g(){f(99);}

//call like this
main(){g();}

Prints 1E100 newlines.

Declaration of i as second parameter of f() not guaranteed to work in all versions of C. Tested on my own machine (GCC on CygWin) and on ideone.com (I believe they also run GCC), but not up to f(99) for obvious reasons!

Level River St

Posted 2016-10-29T18:41:41.303

Reputation: 22 049

1Does that comply with the 4 GiB memory limit? – Dennis – 2016-10-29T20:36:43.867

3@Dennis It should do, it only stores a depth 99 recursion of f,n and i on the stack, getting around the fact that C can´t handle a 100 digit number decimal number. I would estimate a max of about 20 bytes for each instance of f() so about 1980 bytes. The puts dumps the newlines to the API and the API should output and flush the buffer as necessary. – Level River St – 2016-10-29T20:45:33.860

3Tested it locally and memory usage doesn't even surpass 1 MiB. – Dennis – 2016-10-29T22:31:27.630

Declaration of i as second parameter of f() not guaranteed to work in all versions of C.: It could break with a stack-args calling convention where the callee pops args from the stack (or if f writes to stack space that the caller wasn't expecting it to). clang does warn about "too few arguments in call to 'f'", in -std=c89 and -std=c99, so the definition does act as a declaration with a specific number of args. But I forget; I think that might mean the compiler knows the function expects 2 args, and will always leave space for a 2nd arg. – Peter Cordes – 2016-10-31T07:30:41.027

Of course the C standard doesn't say anything about call stacks, but more generally doesn't the visibility of the f(n,i) definition imply that the f(99) call must do whatever is necessary? (Sorry I'm lazy and didn't try to look this up in the standard myself, but in the asm output of clang3.8 -std=c89 -m32 -O2, g() does initialize two 4B spaces on the stack. That's on Linux with a caller-pops calling convention with no register args, but where the called function is allowed to overwrite its args (even though compilers don't make code that does that)) – Peter Cordes – 2016-10-31T07:45:52.043

I used this as a starting point for an x86-64 machine-code version of this, coming in at 30 bytes when using a putchar('\n') libc function call for printing.

– Peter Cordes – 2016-10-31T11:30:44.343

Strictly speaking, "write a program" means you don't really need g but you do need main, don't you? – Felix Dombek – 2017-01-23T07:35:23.573

1

@FelixDombek the community decided a while back that "program" means you can write a program or function unless "full program" is explicitly specified. http://meta.codegolf.stackexchange.com/a/6912/15599 . Therefore my submission comprises g and its helper function f. main would be longer. There are a few other function submissions here, if you look through.

– Level River St – 2017-01-23T23:23:01.303

14

Commodore VIC 20 machine code (40 bytes)

... here shown as hexadecimal:

1040   A9[64]A2 00 9D 68 10 E8  E0[32]D0 F8 A9 00 9D 68
1050   10 A9[31]20 D2 FF A2 00  A9[64]DE 68 10 30 08 D0
1060   F0 9D 68 10 E8 D0 F3 60

(Started using: SYS 4160)

Meaning of the bytes in brackets

  • 0x64 (occurs twice) is the base (100); (values from 2 to 127 should work)
  • 0x32 is the exponent (50) (any non-zero value (1-255) should work)
  • Note that 100^50 = 10^100; running the program 100^50 times is more RAM efficient than doing it 10^100 times
  • 0x31 is the ASCII character to be printed

and at no point no more than 4 GB of memory must be needed.

Is this a typing mistake?

We have the year 1981.

A typical home computer has 1 to 16 KB of RAM! And you will hardly find professional models that have 1 MB or more.

(Ok. Just a joke.)

In other words, the program should in principle be testable by running it on your computer. But because of the extent of this number you will be expected to prove that the number of copies of the string it outputs is exactly 10^100 and that the program stops afterwards.

The program has been tested with other bases and exponents. I have no doubt it will also work with 100 and 50.

At least it does not crash with these numbers (but does not terminate in measurable time either).

The memory size is sufficient for an exponent of 50 and 100 is less than 127 so a base of 100 should not be a problem.

The the basic idea

There is a 50-digit counter that counts in the 100-system. Bytes 0x01-0x64 represent the digits 0-99. The first byte in the counter is the lowest digit. The last byte in the counter (highest digit) is followed by a byte with the value 0x00.

The counter has the initial value 100^50.

An outer loop is writing a byte to the "current channel" ("standard output" on modern systems; typically the screen) and then decrements the counter.

Decrementing is done by an inner loop: It decrements a digit and in the case of an underflow from 1 to 99 it advances to the next digit. If the byte 0x00 at the end of the counter is decremented the program stops.

The assembly code is

    ; Some constants
    base=10
    exponent=100
    character=0x32

    ; Initialize the content of the counter to 100^50
    ; (Fill the first 50 bytes with the value 100)
    lda  #base
    ldx  #0
initLoop:
    sta  counter,x
    inx
    cpx  #exponent
    bne  initLoop
    ; (The terminating 0 at the end of the counter)
    lda  #0
    sta  counter,x

    ; Now do the actual job
outerLoop:
    ; Output a character
    lda  #character
    jsr  (0xFFD2)
    ; Prepare for the inner loop
    ldx  #0
    lda  #base
innerLoop:
    ; Decrement one digit
    dec  counter,x
    ; Result is negative -> must have been the terminating
    ; NUL byte -> Exit
    bmi  progEnd
    ; Result is not zero -> Print the next byte
    bne  outerLoop
    ; Result is zero -> Was 0x01 before -> As 0x01 represents
    ; digit 0 this is an underflow -> set the digit to
    ; "exponent" (100) again (which represents digit 99)
    sta  counter,x
    ; Go to the next digit and...
    inx
    ; ... repeat the inner loop (decrement next digit)
    ; (Note that this conditional branch is ALWAYS taken)
    bne  innerLoop

progEnd:
    rts

counter:
    ; The memory used by the counter is here...

EDIT

The program runs on Commodore C64, too!

Martin Rosenau

Posted 2016-10-29T18:41:41.303

Reputation: 1 921

I borrowed @LevelRiverSt's recursion idea for my x86-64 machine-code implementation, coming in at 30B (using putchar from libc for printing). I considered an extended-precision loop counter, and it would work in x86, too. (And can similarly be pretty cheaply initialized). Maybe I'll try it sometime...

– Peter Cordes – 2016-10-31T11:38:32.020

1LOL wow, I .... <golf clap> ... I haven't seen 6502 assembly in ... well, a long time. – Alex Howansky – 2016-11-01T20:49:48.150

12

Node, 89 bytes

for(i="0".repeat(100)+1;+i;i=i.replace(/0*./,x=>"9".repeat(x.length-1)+~-x))console.log()

Outputs 10100 newlines. (Theoretically, that is; test by replacing 100 with 1 to output 101 newlines instead.)

This works by setting i to the string

00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001

(100 zeroes and a 1; a googol reversed), then repeatedly "subtracting 1" with a regex replace and outputting a newline until the string is all zeroes.

A port of the C++ answer would be 49 bytes:

(f=n=>{for(i=10;i--;)n?f(n-1):console.log()})(99)

ETHproductions

Posted 2016-10-29T18:41:41.303

Reputation: 47 880

1This is genius! Either that or you're an expert at Retina, which doesn't necessarily rule out "genius"... – Patrick Roberts – 2017-01-12T13:45:39.770

7

05AB1E, 6 bytes

Tn°F1?

Explanation

Tn°    # push 10^100
   F   # 10^100 times do
    1? # print 1

Emigna

Posted 2016-10-29T18:41:41.303

Reputation: 50 798

How about the data types? Do they allow integers up to 10^100? – Martin Rosenau – 2016-10-29T19:18:25.787

5@MartinRosenau: Fortunately 05AB1E uses python 3 integers which doesn't have a limit. – Emigna – 2016-10-29T19:24:27.040

@Emigna every integer has its limit. 2^1e9 is a lot, but I'm not sure python can get that high. 1e100 should be well within the range of any big integer, though. – John Dvorak – 2016-10-30T00:05:45.340

1

@JanDvorak: According to the Python 3 docs there is no longer a limit to the value of integers.

– Emigna – 2016-10-30T09:57:50.497

I'm curious if Python can actually handle 4GiB numbers like they say... – John Dvorak – 2016-10-30T09:59:46.657

1@JanDvorak: Indeed. I have used some pretty big numbers without issues (not that big though). We only need to handle 1e100 here though and python can definitely handle that :) – Emigna – 2016-10-30T10:02:30.577

1@JanDvorak The maximum size of Python integers is solely dependent on the amount of available memory. – Mego – 2016-10-30T19:23:10.530

4I have gotten to the limit before while trying to obfuscate a long number. The machine I was using was able to handle numbers bigger than 10^3000 before an integer overflow. – Esolanging Fruit – 2016-10-31T04:04:16.307

6

Ruby, 20 bytes

(10**100).times{p 1}

Prints 1 followed by a newline 1E100 times.

1E100 does not work as it evaluates to a float, not an arbitrary precision integer.

Level River St

Posted 2016-10-29T18:41:41.303

Reputation: 22 049

Can you remove the parentheses? – OldBunny2800 – 2016-10-30T20:11:49.783

1@OldBunny2800 No. methods take priority over operators, so it would be interpreted as 10**(100.times{p 1}) – Level River St – 2016-10-30T21:31:12.620

1For those curious, 1E100.to_i evaluated to 10000000000000000159028911097599180468360808563945281389781327557747838772170381060813469985856815104 on my computer. – Andrew Grimm – 2016-10-31T09:43:41.507

6

Befunge 93, 33 bytes

1>01g0`#@!# _01v
d^.1 **52p10-1g<

Unfortunately, Befunge does not have a power function, so almost all of that code is my implementation of a power function. I'm still working on this.

Explanation:

1 > 01g 0` #@!# _ 01g 1- 01p 25** 1. v
d ^                                  <

1: Start off with 1 in the top left so that when we multiply, we don't get 0 every time.

01g: get the character at position (0, 1), which is d, whose ASCII code is 100.

0`: see if the value stored in (0, 1) is greater than 0; this value will change.

#@!# _: Logical not ! to the value we get from the last step (0 or 1), so that if it was 1, now we have 0, and we Note that # means that you skip the next character in the code.

01g 1- 01p: Take the value stored in (0, 1) again, subtract 1 from it, and store this new value at (0, 1)

25**: multiply the top value of the stack by 10

1.: print 1 every time this loops

1 is printed (in theory) googol times, but that quickly runs off of the page that I tested this on.

You can run Befunge 93 code here. For some reason, the top value of the stack is 1.0000000000000006e+100 when it should be 1.0e+100. I don't know where that 6 came from, but I don't think it should be there and that it may be some rounding error or something like that.

Daniel

Posted 2016-10-29T18:41:41.303

Reputation: 6 425

6

///, 36 ASCII characters (4 distinct)

/t./.ttttt//.t/t\..........//t//t...

Outputs the . character 3*10^125 times, meaning that it outputs the string consisting of 3*10^25 repetitions of the . character, 10^100 times.

Explanation:

  1. /t./.ttttt/: Replace t. with .ttttt throughout the rest of the program, repeating until no instances of t. remain. This replaces t... with ... followed by 125 ts.
  2. /.t/t\........../: Replace .t with t.......... throughout the rest of the program, repeating until no instances of .t remain. This takes the ... followed by 125 ts, and turns it into 125 ts followed by 10^125 occurrences of ....
  3. /t//: Remove all remaining ts.
  4. t...: This gets replaced with 3*10^125 .s. Output them.

Now, outputting 10^100 repetitions of 3*10^25 repetitions of something kind of feels like cheating. This program outputs the . character exactly 10^100 times, using 45 ASCII characters:

/T/tttttttttt//.t/t..........//t//.TTTTTTTTTT

Explanation of this one:

  1. /T/tttttttttt/: Replace T with tttttttttt throughout the rest of the program. This replaces TTTTTTTTTT with 100 repetitions of t.
  2. /.t/t........../: Replace .t with t.......... throughout the rest of the program. This takes the . followed by 100 ts, and turns it into 100 ts followed by 10^100 .s.
  3. /t//: Remove all remaining ts.
  4. .TTTTTTTTTT: This gets replaced with 10^100 .s. Output them.

Finally, here's a compromise program, which outputs the . character 2*10^100 times, using 40 characters:

/t./.tttttttttt//.t/t\..........//t//t..

Tanner Swett

Posted 2016-10-29T18:41:41.303

Reputation: 531

4

ABCR, 56 bytes

++++++++++AAAAAAAAAA7a*A!(x4bBBBBBBBBBB7b+B@(xa(Ax5b(Box

Turing tarpits are fun, especially when they don't have easy multiplication or exponents. On the other hand, I only needed to use two of the three queues!

Explanation:

++++++++++                                             Set register to 10
          AAAAAAAAAA                                   Queue 10 to queue A 10 times
                    7a*A!(x                            Sum up all of queue A by:
                    7     x                             While the register is truthy:
                     a*                                 Dequeue two elements of A, sum them...
                       A                                ...and queue the result back to A.
                        !(                              If there's only one element left,
                                                        i.e. !(A.len - 1),
                                                        break from the loop.  A now has 100, our exponent.

                             4                        While A's front is truthy:
                              bBBBBBBBBBB              Clone the front of B 10 (our base) times.  (The first iteration fills it up with ten 1s)
                                         7b+B@(x       Sum up all of queue B like we did with A
                                                a(A    Decrement a (so that the loop actually ends. Runs 101 times like it should) x   

                                                       B now contains 10^100 only.

                                                   5b(B x   10^100 times:
                                                       o     print the front of queue A (0)

Steven H.

Posted 2016-10-29T18:41:41.303

Reputation: 2 841

4

Batch, 574 242 bytes

@echo off
set t=for /l %%a in (2,1,33554432)do call:
set f=for /l %%a in (2,1,9765625)do call:
%t%a
:a
%t%b
:b
%t%c
:c
%t%d
:d
%f%e
:e
%f%f
:f
%f%g
:g
%f%h
:h
%f%i
:i
%f%j
:j
%f%k
:k
%f%l
:l
%f%m
:m
%f%n
:n
echo

Each loop falls through therefore executing an additional iteration. Loops are limited to ~2³² due to the 32-bit integer limit. The first four loops each count 2²⁵ for a total of 2¹⁰⁰ while the remaining ten loops each count 5¹⁰ for a total of 5¹⁰⁰.

Edit: Saved an unimaginable 58% thanks to @ConorO'Brien.

Neil

Posted 2016-10-29T18:41:41.303

Reputation: 95 035

1I golfed it down considerably. – Conor O'Brien – 2016-10-30T02:10:34.530

1@ConorO'Brien Wait, you can do that? I never knew! – Neil – 2016-10-30T10:13:11.320

4

TI-Basic, 20 bytes

Straightforward. Only eight lines are displayed at once, and previous lines do not stay in memory. Because ᴇ100 is unsupported, we must loop from -ᴇ99 to 9ᴇ99. Then, if I!=0, display the string (which, by the way, is 3). This way, we print it exactly ᴇ100 times.

For(I,-ᴇ99,9ᴇ99:If I:Disp 3:End

Timtech

Posted 2016-10-29T18:41:41.303

Reputation: 12 038

Are you sure the variable "I" is precise enough to store 99 digits? – Martin Rosenau – 2016-10-30T11:33:52.827

Alright, yes, I should be enough to hold that, although it would only display up to 14 if using "Disp", but we don't actually output it, only check if it does not equal zero. Also, you're right about the symbol, but I figured you would understand what I mean. I'll copy that into my post now. – Timtech – 2016-10-30T21:42:49.413

I have never encountered a version of BASIC with infinite integers but that doesn't even matter as your loop doesn't execute nearly enough times. – Loren Pechtel – 2016-11-01T00:20:34.447

1Umm yea, there's no infinite integers here. Integers must be within +-10^100 – Timtech – 2016-11-01T23:18:53.000

4

PHP, 44 bytes

for($i=bcpow(10,1e2);$i=bcsub($i,print 1););

This snippet will output 1 googol times. It will not run out of memory, but it is terribly slow. I'm using BCMath to be able to handle long integers.

A bit better performing, but not as small (74 bytes):

for($m=bcpow(10,100);$m;$m=bcsub($m,$a))echo str_repeat(a,$a=min(4e9,$m));

Will output the letter a googol times. It will consume almost 4GB of memory, outputting about 4e9 characters at a time.

chocochaos

Posted 2016-10-29T18:41:41.303

Reputation: 547

if just an 'a' takes almost 4GB, what would 'aaa' do? It will take more code, but with ob_flush(); you might go a lot further – Martijn – 2016-10-31T10:45:31.957

Uhm, it's not one a, it's a string of 4*10^9 as. There no way not go over the 4GB if you're going to put 3 times as many as in there. Ob_flush has nothing to do with it, the point of the second example is to output large strings at once instead of outputting small amounts of characters each time, which results in the program running quite a bit faster, at the cost of more memory usage. – chocochaos – 2016-10-31T11:25:46.880

As far as I know ">=" is not able to handle big integers, you should use bccomp – Crypto – 2016-10-31T12:48:41.360

You are correct, it doesn't give the correct results when comparing strings. I will fix it in a minute. – chocochaos – 2016-10-31T13:07:23.143

Edit with a somewhat different but working solution :) – chocochaos – 2016-10-31T13:23:16.897

4

x86-64 machine code function, 30 bytes.

Uses the same recursion logic as the C answer by @Level River St. (Max recursion depth = 100)

Uses the puts(3) function from libc, which normal executables are linked against anyway. It's callable using the x86-64 System V ABI, i.e. from C on Linux or OS X, and doesn't clobber any registers it's not supposed to.


objdump -drwC -Mintel output, commented with explanation

0000000000400340 <g>:  ## wrapper function
  400340:       6a 64                   push   0x64
  400342:       5f                      pop    rdi       ; mov edi, 100  in 3 bytes instead of 5
  ; tailcall f by falling into it.

0000000000400343 <f>:  ## the recursive function
  400343:       ff cf                   dec    edi
  400345:       97                      xchg   edi,eax
  400346:       6a 0a                   push   0xa
  400348:       5f                      pop    rdi       ; mov edi, 10
  400349:       0f 8c d1 ff ff ff       jl     400320 <putchar>   # conditional tailcall
; if we don't tailcall, then eax=--n = arg for next recursion depth, and edi = 10 = '\n'

  40034f:       89 f9                   mov    ecx,edi   ; loop count = the ASCII code for newline; saves us one byte


0000000000400351 <f.loop>:
  400351:       50                      push   rax       ; save local state
  400352:       51                      push   rcx
  400353:       97                      xchg   edi,eax   ; arg goes in rdi
  400354:       e8 ea ff ff ff          call   400343 <f>
  400359:       59                      pop    rcx       ; and restore it after recursing
  40035a:       58                      pop    rax
  40035b:       e2 f4                   loop   400351 <f.loop>
  40035d:       c3                      ret    
# the function ends here

000000000040035e <_start>:

0x040035e - 0x0400340 = 30 bytes

# not counted: a caller that passes argc-1 to f() instead of calling g
000000000040035e <_start>:
  40035e:       8b 3c 24                mov    edi,DWORD PTR [rsp]
  400361:       ff cf                   dec    edi
  400363:       e8 db ff ff ff          call   400343 <f>
  400368:       e8 c3 ff ff ff          call   400330 <exit@plt>    # flush I/O buffers, which the _exit system call (eax=60) doesn't do.

Built with yasm -felf64 -Worphan-labels -gdwarf2 golf-googol.asm && gcc -nostartfiles -o golf-googol golf-googol.o. I can post the original NASM source, but that seemed like clutter since the asm instructions are right there in the disassembly.

putchar@plt is less than 128 bytes away from the jl, so I could have used a 2-byte short jump instead of a 6-byte near jump, but that's only true in a tiny executable, not as part of a larger program. So I don't think I can justify not counting the size of libc's puts implementation if I also take advantage of a short jcc encoding to reach it.

Each level of recursion uses 24B of stack space (2 pushes and the return address pushed by CALL). Every other depth will call putchar with the stack only aligned by 8, not 16, so this does violate the ABI. A stdio implementation that used aligned stores to spill xmm registers to the stack would fault. But glibc's putchar doesn't do that, writing to a pipe with full buffering or writing to a terminal with line buffering. Tested on Ubuntu 15.10. This could be fixed with a dummy push/pop in the .loop, to offset the stack by another 8 before the recursive call.


Proof that it prints the right number of newlines:

   # with a version that uses argc-1  (i.e. the shell's $i)  instead of a fixed 100
$ for i in {0..8}; do echo -n "$i: "; ./golf-googol $(seq $i) |wc -c; done
0: 1
1: 10
2: 100
3: 1000
4: 10000
5: 100000
6: 1000000
7: 10000000
8: 100000000
... output = 10^n newlines every time.

My first version of this was 43B, and used puts() on a buffer of 9 newlines (and a terminating 0 byte), so puts would append the 10th. That recursion base-case was even closer to the C inspiration.

Factoring 10^100 a different way could maybe have shortened the buffer, maybe down to 4 newlines, saving 5 bytes, but using putchar is better by far. It only needs an integer arg, not a pointer, and no buffer at all. The C standard allows implementations where it's a macro for putc(val, stdout), but in glibc it exists as a real function that you can call from asm.

Printing only one newline per call instead of 10 just means we need to increase the recursion max depth by 1, to get another factor of 10 newlines. Since 99 and 100 can both be represented by a sign-extended 8-bit immediate, push 100 is still only 2 bytes.

Even better, having 10 in a register works as both a newline and a loop counter, saving a byte.

Ideas for saving bytes

A 32-bit version could save a byte for the dec edi, but the stack-args calling convention (for library functions like putchar) makes tail-call work less easily, and would probably require more bytes in more places. I could use a register-arg convention for the private f(), only called by g(), but then I couldn't tail-call putchar (because f() and putchar() would take a different number of stack-args).

It would be possible to have f() preserve the caller's state, instead of doing the save/restore in the caller. That probably sucks, though, because it would probably need to get separately in each side of the branch, and isn't compatible with tailcalling. I tried it but didn't find any savings.

Keeping a loop counter on the stack (instead of push/popping rcx in the loop) didn't help either. It was 1B worse with the version that used puts, and probably even more of a loss with this version that sets up rcx more cheaply.

Peter Cordes

Posted 2016-10-29T18:41:41.303

Reputation: 2 810

2Hooray for assembly answers! :) – None – 2016-10-31T13:35:05.947

3

Haskell, 45 43 bytes

r 0=[]
r i='1':r(i-1)
main=putStr.r$10^100

Angs

Posted 2016-10-29T18:41:41.303

Reputation: 4 825

3

Pyke, 6 5 bytes

TTX^V

Try it here!

Untested as it crashes my browser. The first 4 chars generate 10^100 and V prints out that many newlines. Test with 100V.

Blue

Posted 2016-10-29T18:41:41.303

Reputation: 26 661

3

Racket 36 bytes

(for((i(expt 10 100)))(display "1"))

Output:

1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...

rnso

Posted 2016-10-29T18:41:41.303

Reputation: 1 635

3

JAISBaL, 4 bytes

˖Q

Chrome can't read all the symbols, and I'm not sure about other browsers, so here's a picture:

Explanation:

# \# enable verbose parsing #\
10^100       \# [0] push 10^100 onto the stack #\
for          \# [1] start for loop #\
    space    \# [2] print a space #\

Pretty simple.... just prints a googol spaces. Three instructions, but the googol constant is two bytes.

(Written in version 3.0.5)

Socratic Phoenix

Posted 2016-10-29T18:41:41.303

Reputation: 1 629

This is 6 UTF-8 bytes. Which encoding are you using? – Conor O'Brien – 2016-10-30T02:11:38.560

"bytes" does link to it... – Socratic Phoenix – 2016-10-30T02:57:41.027

Gah, sorry. I have a userscript that makes links look like regular text. – Conor O'Brien – 2016-10-30T02:58:18.323

Oh, I didn't know that was possible, okay :) – Socratic Phoenix – 2016-10-30T02:58:56.150

@ConorO'Brien umm, why? – Cyoce – 2016-10-30T16:57:47.203

@Cyoce It's accidental to the userscript, not integral. – Conor O'Brien – 2016-10-30T16:58:20.767

3

JavaScript ES6, 85 83 bytes

Saved 2 bytes thanks to ETHproductions!

eval([...Array(i=100)].map(_=>`for($${--i}=0;$${i}++<10;)`).join``+"console.log()")

This prints 1e100 newlines.

The inner part generates this program, which is thereafter evaluated.

for($0=0;$0++<10;)for($1=0;$1++<10;)for($2=0;$2++<10;)for($3=0;$3++<10;)for($4=0;$4++<10;)for($5=0;$5++<10;)for($6=0;$6++<10;)for($7=0;$7++<10;)for($8=0;$8++<10;)for($9=0;$9++<10;)for($10=0;$10++<10;)for($11=0;$11++<10;)for($12=0;$12++<10;)for($13=0;$13++<10;)for($14=0;$14++<10;)for($15=0;$15++<10;)for($16=0;$16++<10;)for($17=0;$17++<10;)for($18=0;$18++<10;)for($19=0;$19++<10;)for($20=0;$20++<10;)for($21=0;$21++<10;)for($22=0;$22++<10;)for($23=0;$23++<10;)for($24=0;$24++<10;)for($25=0;$25++<10;)for($26=0;$26++<10;)for($27=0;$27++<10;)for($28=0;$28++<10;)for($29=0;$29++<10;)for($30=0;$30++<10;)for($31=0;$31++<10;)for($32=0;$32++<10;)for($33=0;$33++<10;)for($34=0;$34++<10;)for($35=0;$35++<10;)for($36=0;$36++<10;)for($37=0;$37++<10;)for($38=0;$38++<10;)for($39=0;$39++<10;)for($40=0;$40++<10;)for($41=0;$41++<10;)for($42=0;$42++<10;)for($43=0;$43++<10;)for($44=0;$44++<10;)for($45=0;$45++<10;)for($46=0;$46++<10;)for($47=0;$47++<10;)for($48=0;$48++<10;)for($49=0;$49++<10;)for($50=0;$50++<10;)for($51=0;$51++<10;)for($52=0;$52++<10;)for($53=0;$53++<10;)for($54=0;$54++<10;)for($55=0;$55++<10;)for($56=0;$56++<10;)for($57=0;$57++<10;)for($58=0;$58++<10;)for($59=0;$59++<10;)for($60=0;$60++<10;)for($61=0;$61++<10;)for($62=0;$62++<10;)for($63=0;$63++<10;)for($64=0;$64++<10;)for($65=0;$65++<10;)for($66=0;$66++<10;)for($67=0;$67++<10;)for($68=0;$68++<10;)for($69=0;$69++<10;)for($70=0;$70++<10;)for($71=0;$71++<10;)for($72=0;$72++<10;)for($73=0;$73++<10;)for($74=0;$74++<10;)for($75=0;$75++<10;)for($76=0;$76++<10;)for($77=0;$77++<10;)for($78=0;$78++<10;)for($79=0;$79++<10;)for($80=0;$80++<10;)for($81=0;$81++<10;)for($82=0;$82++<10;)for($83=0;$83++<10;)for($84=0;$84++<10;)for($85=0;$85++<10;)for($86=0;$86++<10;)for($87=0;$87++<10;)for($88=0;$88++<10;)for($89=0;$89++<10;)for($90=0;$90++<10;)for($91=0;$91++<10;)for($92=0;$92++<10;)for($93=0;$93++<10;)for($94=0;$94++<10;)for($95=0;$95++<10;)for($96=0;$96++<10;)for($97=0;$97++<10;)for($98=0;$98++<10;)for($99=0;$99++<10;)console.log()

Now, for a proof of correctness, we'll use some induction. Let's substitute the initial 100 for other values, generically N. I claim that inserting N will yield 10N newlines. Let's pipe the result of this to wc -l, which counts the number of newlines in the input. We'll use this modified but equivalent script that takes input N:

eval([...Array(+process.argv[2])].map(_=>`for($${i}=0;$${i++}++<10;)`,i=0).join``+"console.log()")

Now, here's some output:

C:\Users\Conor O'Brien\Documents\Programming
λ node googol.es6 1 | wc -l
10

C:\Users\Conor O'Brien\Documents\Programming
λ node googol.es6 2 | wc -l
100

C:\Users\Conor O'Brien\Documents\Programming
λ node googol.es6 3 | wc -l
1000

C:\Users\Conor O'Brien\Documents\Programming
λ node googol.es6 4 | wc -l
10000

We can see that this transforms the input N for small values to 10N newlines.

Here is an example output for N = 1:

C:\Users\Conor O'Brien\Documents\Programming
λ node googol.es6 1











C:\Users\Conor O'Brien\Documents\Programming
λ

Conor O'Brien

Posted 2016-10-29T18:41:41.303

Reputation: 36 228

Nice. Save a couple bytes with eval([...Array(i=100)].map(_=>`for($${--i}=0;$${i}++<10;)`).join``+"console.log()") – ETHproductions – 2016-10-30T14:16:51.217

@ETHproductions thanks! :D – Conor O'Brien – 2016-10-30T14:51:26.153

P.S. I count 83 bytes ;) – ETHproductions – 2016-10-30T17:34:55.123

Another example here. Not sure if it's useful to anyone else, but I wasn't quite sure how this worked and wrote a wrapper function for the eval'd function to play with. You can clearly see the program counting to 10^n, where n is the number of loops evaluated. I set a return condition so it breaks well before googol; change the variable used in that condition to count through different loop levels. Also, a nitpick: your second code sample shows the outer loop being $0, going down to $99; it should be reversed, with $99 being the outer loop.

– MichaelS – 2016-10-31T00:04:45.417

@MichaelS true. I will change it the next chance I get. – Conor O'Brien – 2016-10-31T00:47:06.907

3

Mathematica, 48 30 25 bytes

For[n=1,n++<Echo@1*^100,]

Output:

>> 10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
>> 10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
>> 10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
>> 10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
>> 10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
etc.

LegionMammal978

Posted 2016-10-29T18:41:41.303

Reputation: 15 731

Can't test right now, but how about For[n=0,n++<10^100,Echo[]]? – Martin Ender – 2016-10-31T17:31:34.283

I'd consider the leading >> part of the output. They're printed if you use Echo on the console. – Martin Ender – 2016-11-01T01:23:07.073

@MartinEnder Whoops, fixed – LegionMammal978 – 2016-11-01T01:25:05.703

How about Echo@0&~Array~10^100; for 21 bytes? – Greg Martin – 2017-01-08T19:06:45.560

3

Fortran 95, Free-form, Recursive, 117 bytes

Program M
Call R(99)
END
Recursive Subroutine R(L)
IF(L)3,1,1
1 DO 2 I=1,10
2 Call R(L-1)
RETURN
3 PRINT*,0
END

Prints a googol of lines containing

          0

Fortran 90, Recursive, 149 bytes

     CallR(99)
     END
     RecursiveSubroutineR(L)
     IF(L)3,1,1
   1 DO2I=1,10
   2 CallR(L-1)
     RETURN
   3 PRINT*,0
     END     

Recursively calling 100 nested loops, each 10 iterations, makes exactly one googol. N, L, and the loop counters all fit in byte-sized integers.

Tested by replacing 99 with 1, 2, 3, 4, 5 and noting that in each case the resulting line count from "wc" has n+1 zeros.

Fortran II, IV, 66, or 77, 231 bytes:

      N=2*10**9
      DO1I0=1,5**10
      DO1I=1,N
      DO1J=1,N
      DO1K=1,N
      DO1L=1,N
      DO1M=1,N
      DO1I1=1,N
      DO1J1=1,N
      DO1K1=1,N
      DO1L1=1,N
      DO1M1=1,N
1     PRINT2
2     FORMAT(X)
      END

Prints a googol of newlines.

All of these programs will run on 32-bit machines; in fact, the recursive versions would work just fine on a 16-bit machine. One could use fewer loops in the brute-force version by running on an old Cray with its 60-bit integers. Here, ten nested loops of 2*10^9 inside one loop of 5^10 (9765625) equals 10 ^ 100 total iterations.

None of the versions uses any memory to speak of other than the object code itself, the counters, one copy of the output string, and, in the recursive version, a 100-level return stack.

Check the factors by comparing

bc<<<2000000000\^10*5\^10
bc<<<10\^100

Glenn Randers-Pehrson

Posted 2016-10-29T18:41:41.303

Reputation: 1 877

3

Turing machine simulator, 1082 bytes

0 * 6 r 1
1 * E r 2
2 * C r 3
3 * 1 r 4
4 * B r 5
5 * C r 6
6 * F r 7
7 * 4 r 8
8 * 6 r 9
9 * 8 r A
A * 8 r B
B * 3 r C
C * 0 r D
D * 9 r E
E * G r F
F * H r G
G * 8 r H
H * 0 r I
I * 6 r J
J * H r K
K * 9 r L
L * 3 r M
M * 2 r N
N * A r O
O * D r P
P * C r Q
Q * C r R
R * 4 r S
S * 4 r T
T * E r U
U * E r V
V * G r W
W * 6 r X
X * D r Y
Y * E r Z
Z * 0 r a
a * F r b
b * E r c
c * 9 r d
d * F r e
e * A r f
f * H r g
g * D r h
h * E r i
i * 6 r j
j * 6 r k
k * D r l
l * G r m
m * H r n
n * 1 r o
o * 0 r p
p * 8 r q
q * C r r
r * 9 r s
s * G r t
t * 3 r u
u * 6 r v
v * 2 r w
w * 3 r x
x * E r y
y * 0 r z
z * 4 r +
+ * 5 r /
/ * A r =
= * 0 r -
- * H r \
\ * 7 r !
! * A r @
@ * 9 r #
# * 5 r $
$ * A r %
% * B r ^
^ * 5 r &
& * 9 r ?
? * 4 r (
( * C r )
) * E r `
` * 9 r ~
~ * 9 r _
_ * A * .
. 0 I l *
. 1 0 r <
. 2 1 r <
. 3 2 r <
. 4 3 r <
. 5 4 r <
. 6 5 r <
. 7 6 r <
. 8 7 r <
. 9 8 r <
. A 9 r <
. B A r <
. C B r <
. D C r <
. E D r <
. F E r <
. G F r <
. H G r <
. I H r <
. _ * r ]
< _ * r >
< * * r *
> _ = l [
> * * r *
[ _ * l .
[ * * l *
] _ * * halt
] * _ r *

Turing machine simulator

I do not know if this counts as the correct output, since it has 82 leading spaces.

I do not know if this respects the 4 GB limit, so, if it doesn't, then it's non-competitive and just for showcase. The output is 1e100 bytes, so that should be deducted from the memory byte count. The final byte count is 82 bytes.

Here is an explanation:

The first 80 lines of code are 80 different states that generate the base-191 loop count 6EC1BCF4688309GH806H932ADCC44EEG6DE0FE9FAHDE66DGH108C9G3623E045A0H7A95AB594CE99A.

The next 19 lines of code are the counter state, which decrements the count every time a character is printed.

The next 6 lines are the printer state, which appends an =.

Finally, the last 2 lines are the cleaner state, which are needed to make sure the only output is =====...=====. Leading/trailing spaces do not count as output, since they are unavoidable side-effects.

The program then halts.

1I did the math for that.

Erik the Outgolfer

Posted 2016-10-29T18:41:41.303

Reputation: 38 134

2

Brainfuck, 45 bytes

->-[[->+<]+>-]<[[>-<-[>[----->]]>[<]<].<[+]<]

It outputs 254×250255 null bytes and exits with an error.

Brainfuck, 50 48 bytes, without errors

>>>->-[[->+<]+>-]<[[>-<-[>[----->]]>[<]<]<[.+]<]

It outputs 254×250255 times \xfa\xfb\xfc\xfd\xfe\xff, and 1524×250255 bytes in total.

jimmy23013

Posted 2016-10-29T18:41:41.303

Reputation: 34 042

2

Pyth, 8 7 bytes

V^T100G

Link

Solution is tested with small output, but it should print abcdefghijklmnopqrstuvwxyz 1e100 times.

For some reason, the p was unneeded, as 31343 (Maltysen) said.

Erik the Outgolfer

Posted 2016-10-29T18:41:41.303

Reputation: 38 134

Why is the p needed? – Maltysen – 2016-10-30T03:26:55.607

@Maltysen I think because of the 4 GB limit. – Erik the Outgolfer – 2016-10-30T06:18:02.507

Why? Cuz of the buffer? Doesn't that automatically flush? – Maltysen – 2016-10-30T16:04:56.480

@Maltysen I don't know, the online interpreter does not have immediate output functionality. It might flush, it might not... – Erik the Outgolfer – 2016-10-30T16:08:08.623

Its working locally without the p – Maltysen – 2016-11-01T23:03:03.267

@Maltysen Oh, I thought it took more than 4 gigabytes of RAM, but it apparently doesn't? – Erik the Outgolfer – 2016-11-01T23:05:57.633

2

Pyth, 7 Bytes

New (Competing)

V^T*TTG

Explanation

G=The alphabet
Repeat 10^(10*10) times
    print(G)

Old (Non Competing) 7 Bytes

*G^T*TT

Explanation

G=The alphabet
G*(10^(10*10))==G*10^100

Dignissimus - Spammy

Posted 2016-10-29T18:41:41.303

Reputation: 449

1This doesn't comply with the 4 GiB remory limit. – Dennis – 2016-10-29T20:38:13.067

@Dennis I fixed it – Dignissimus - Spammy – 2016-10-29T20:49:37.447

Not a golfing advice, but I don't think *TT is any shorter than a plain 100. – Erik the Outgolfer – 2017-01-26T12:06:53.163

2

Java, 198 179 155 bytes

import java.math.*;class a{void A(a[]x){for(BigInteger b=BigInteger.ZERO;!(b=b.add(BigInteger.ONE)).equals(BigInteger.TEN.pow(100));)System.out.print(x);}}

Prints (x == null ? null : a string that starts with [La;@ or something like that) 10100 times in O(forever) time.

user8397947

Posted 2016-10-29T18:41:41.303

Reputation: 1 242

3You have a class, but no public static void main(String[]a) method. As for golfing tips: you can replace the new BigInteger("0"), new BigInteger("1") and new BigInteger("10") with BigInteger.ZERO, BigInteger.ONE and BigInteger.TEN; you can replace import java.math.BigInteger; with import java.math.*;. – Kevin Cruijssen – 2016-10-31T09:35:49.123

1No need for imports: something similar to this should work: java.math.BigInteger b=null;for(b=b.ZERO;!(b=b.add(b.ONE)).equals(b.TEN.pow(100);)System.out.print(x); – Olivier Grégoire – 2016-10-31T13:41:54.650

@OlivierGrégoire That gives me a NullReferenceException, possibly because b is null. – Xanderhall – 2016-12-07T13:23:13.300

@Xanderhall you probably tried this in C# (because you said NRE, not NPE). I can't test the Java version right now so I can't tell what's wrong. In any case, I said "should work", not "will work". The idea to take is that you can have static method calls on instance references, even null ones. – Olivier Grégoire – 2016-12-09T12:00:44.483

@OlivierGrégoire I tried it in Java. I don't code in C#. – Xanderhall – 2016-12-09T13:05:55.553

@Xanderhall I "only" missed one parenthesis, so "something similar" is totally good enough in my first comment. The full program, for 126 bytes is the following: class A{void A(A[]x){java.math.BigInteger b=null;for(b=b.ZERO;!(b=b.add(b.ONE)).equals(b.TEN.pow(100));)System.out.print(x);}}. And it works. I tested it before posting. – Olivier Grégoire – 2016-12-09T17:40:53.137

@OlivierGrégoire I would've sworn I copied it exactly as it was and it didn't work (and that was after fixing the bracket), hence my comment. It's working now. – Xanderhall – 2016-12-09T17:48:26.773

@Xanderhall (my last comment on this issue) you probably encountered this bug.

– Olivier Grégoire – 2016-12-09T17:53:00.003

2

Python 3, 32 bytes

for i in range(10**100):print()

Alternate solution, 33 bytes:

[print()for i in range(10**100)]

Elronnd

Posted 2016-10-29T18:41:41.303

Reputation: 101

In Python 2 this is a particularly great answer. – None – 2016-10-31T13:35:37.970

1Not so much, @Lembik. In Python 2, range(10**100) creates a list of numbers [1, 2, 3, 4, ...], which results in OverflowError: range() result has too many items. This would work in Python 2 with a call to xrange() instead, and works in Python 3 since xrange() was renamed to range(), and the original range() that generated a list was deprecated. – James Murphy – 2016-11-01T00:16:33.500

2@JamesMurphyb Yes I know that. I was trying to be funny about the impractability of codegolf answers. – None – 2016-11-01T07:51:11.870

1Sorry. I have trouble reading humor in a lot of SE comments. – James Murphy – 2016-11-02T02:51:50.613

2

Java, 153 bytes

import java.math.*;interface M{static void main(String[]a){for(BigInteger i=BigInteger.ZERO;!i.add(i.ONE).equals(i.TEN.pow(100));)System.out.print(1);}}

Output: 1e100 1s

I know there is another Java answer which is also pretty close. Mine's got a main and is still shorter though.

This is my first code-golf entry. Tips appreciated.

Niclas M

Posted 2016-10-29T18:41:41.303

Reputation: 61

This can be golfed to 117 bytes by using lambda. You still need to include the import, however. import java.math.*;()->{for(BigInteger i=BigInteger.ZERO;!i.add(i.ONE).equals(i.TEN.pow(100));)System.out.print(1);}; – Shaun Wild – 2016-11-02T09:21:43.560

@BasicallyAlanTuring Actually my javac won't let me compile this. – Niclas M – 2016-11-02T19:48:58.700

Update your Java then. Also, this is not complete compilable code. Just the bare minimum allowed for an entry. – Shaun Wild – 2016-11-03T09:05:42.370

@BasicallyAlanTuring Got Java 8. I guess functions are not allowed by the OP. – Niclas M – 2016-11-03T09:25:44.533

The code I have given you is not a complete program.. It's just what's required to be a valid CG answer. – Shaun Wild – 2016-11-03T11:06:04.600

@BasicallyAlanTuring Functions are enough even if the OP doesn't state so? Thank you! – Niclas M – 2016-11-03T11:47:28.837

Yes generally. Unless the OP specifically asks for a full program. – Shaun Wild – 2016-11-03T15:38:57.253

@BasicallyAlanTuring He actually stated he's interested in seeing programs. – Niclas M – 2016-11-03T15:47:22.357

2

PHP, 39 38 bytes

for($a=str_pad(e,99,0);T^$a++;)echo!0;

Run like this:

php -r 'for($a=str_pad(e,99,0);T^$a++;)echo!0;' 2>/dev/null

STDERR (34 bytes)

If a variant with output to STDERR is valid, then this outputs PHP Notice: Use of undefined constant T - assumed 'T' in Command line code on line 1 a googol times.

php -r 'for($a=str_pad(@e,99,0);T^++$a;);'

Explanation

for (
    $a = str_pad("e", 99, "0"); // Creates a string "e000" (98 zeroes).
    "T" ^ $a++;                 // Increment the string, binary XOR with
                                // "T": when the alphabetic part of the 
                                // string becomes "da" this results in 
                                // falsy "0", ending the loop.
)
    echo!0;                     // Print a single "1".

Note that the alphabetic part iterates from e..z (22), aa..az (26), ba..bz (26), ca..cz (26) for a total of 100, or a 1 with 2 zeroes. So only 98 zeroes need to be added to arrive at 1E100. The loop stops only when the alphabetic part is 2 digits and the second digit becomes d. The d is conveniently skipped when it's only 1 digit (since it starts at e).

Perf

This doesn't consume a ridiculous amount of resources (in fact very little) and runs fast.

Tweaks

  • Saved a byte by using 2 alphabetic chars so less padding characters (99 vs 101)
  • Added a variant using STDERR, saving 5 bytes

aross

Posted 2016-10-29T18:41:41.303

Reputation: 1 583

1Your code must be within <?php tags, even if it is a pure .php file. However, in a PHP file, you can omit the closing ?> tag. Just saying. – ckjbgames – 2017-01-23T22:27:48.060

@ckjbgames wrong. Ever tried running code with php -r? In any case, here's the relevant discussion about that.

– aross – 2017-01-24T08:49:32.823

You would need to if it was meant to be on a webpage. – ckjbgames – 2017-01-24T14:15:57.650

1

LOLCODE, 224 bytes

HAI 1.2
I HAS A n ITZ A NUMBR
n R 10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
IM IN YR loop UPPIN YR v TIL BOTH SAEM v AN n
BTW THIS WHERE I PRINT
VISIBLE "HAI!!1"
IM OUTTA YR loop
KTHXBYE

I had absolutely no idea how to calculate 10100, so why not just write it out? Apparently, there's no ^ operator or power function in LOLCODE.

I didn't count the bytes for the BTW part, since it's a comment for explaining the code. "explain"

Also, my ressource didn't quite explain how datatypes work in-depth, so we can only assume that NUMBR can store this much.

devRicher

Posted 2016-10-29T18:41:41.303

Reputation: 1 609

Try I HAS A b ITZ A NUMBR b R 10 I HAS A n ITZ A NUMBR n R PRODUKT OF b AN PRODUKT OF b AN n instead of using n R 10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000. – ckjbgames – 2017-01-23T22:23:47.987

1

Perl 6, 18 bytes

say 1 for ^10**100

Notes:

  • Perl 6 integers have no upper limit, so 10**100 calculates the googol just fine.
  • The ^n syntax is short for 0 ..^ n, which constructs a range from 0 (inclusive) to n (not inclusive), which conceptually contains n integers but is stored as a memory-efficient Range object.
  • The for loop iterates over it without keeping already iterated elements in memory, so the program's RAM usage will remain pretty stable - and far below 4 GB - throughout its runtime.

smls

Posted 2016-10-29T18:41:41.303

Reputation: 4 352

1

Actually, 9 bytes

2╤╤DW;Y.D

Try it online!

This takes a really long time to run. Here is a faster version that only prints 100 zeroes.

Explanation:

2╤╤DW;Y.D
2╤╤         push 10**(10**2)
   D        subtract 1
    W       while the value on top of the stack is truthy:
     ;Y.      duplicate it, boolean negate it (0 if truthy, 1 if falsey), pop it and print it
        D     decrement the other copy
            (after the while loop finished, (10**100)-1 zeroes will have been printed, separated by newlines)
            implicitly print the only stack value (0), followed by a newline

Mego

Posted 2016-10-29T18:41:41.303

Reputation: 32 998

Does this fit within the memory requirements of the challenge? sys.getsizeof(1) returns 28, and so storing a googol copies of 1 would take 2.8 × 10^89 TB, but the challenge restricts memory to 4GB. I may be wrong though, I don't know how Actually is interpreted. – FlipTack – 2017-01-23T22:57:50.897

@FlipTack In Python (the language that Actually is written in), small integers (under 256, I believe) are not unique objects - there is only ever one 1. Thus, this program just contains a googol references to 1, which are much smaller than the actual object. I don't know the memory impact of multiple references to 1, though, so it may still violate the memory limit. I'll change it to something that definitely doesn't run afoul. – Mego – 2017-01-23T23:01:29.550

I don't think storing a googol of anything is possible, whether it be integers or references. Even just storing a googol bits needs 1.25 × 1087 terabytes. So the new solution seems more sensible. – FlipTack – 2017-01-25T21:03:56.373

I meant 1.25 x 10^87 (missed the exponent) – FlipTack – 2017-01-26T10:29:02.573

1

Pushy, 5 bytes

Non-competing as the language postdates the challenge.

THe:"

Prints 10100 newlines. You can Try it online, but output is truncated at 100KB, and the site becomes very unresponsive when you run it.

T      \ Push 10
 H     \ Push 100
  e    \ Exponentiate - pops both and computes 10 ^ 100
   :   \ Pop the googol and that many times do:
    "  \   Print the whole stack - just a newline, as it's now empty.

You can verify this generates a googol by running THe# in the online interpreter. The reference implementation is in Python and therefore has no upper limit on integer size. The googol itself does not take too much data to store, in fact you only need 333 bits to store an integer of that size (although as Python integer this seems to take up 58 bytes) - nowhere near the memory restriction on this challenge.

FlipTack

Posted 2016-10-29T18:41:41.303

Reputation: 13 242

1

Bash, 72 71 bytes

Prints 10^100 at signs.
Saved 1 byte thanks to @FlipTack.

printf '@%.0s' $(eval echo $(seq 1 $(echo 10^100 | bc | tr "\n" "\0"))) 

WARNING: This is probably extremely slow.


This is my first code golf, so I hope I did well.

ckjbgames

Posted 2016-10-29T18:41:41.303

Reputation: 1 287

I think you've misunderstood the question. You don't take the string to print as input, you can print any string you want a googol times, whatever string is shortest for you to print – FlipTack – 2017-01-23T22:54:29.163

@FlipTack Thanks! One byte saved. – ckjbgames – 2017-01-23T22:55:02.600

1

TrumpScript 189 bytes

I is 10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000A is,I -I;We is 1000001 -1000000as long as,I >A;:say,A;I is,I -We;!America is great

Try it online!

Unfortunately 100 bytes taken up by the number as TrumpScript has no exponentials

Explanation

I is googol (using googol for clarity) sets the variable I to 10^100

A is I -I sets A to 0. 0 in the code as a number is invalid as all number must be > 1000000

We is 1000001 -1000000 assigns we as 1

as long as, I > A;: starts while loop checking that I > 0

say A prints out 0

I is,I -We subtracts 1 from I

America is great ends the program

user63571

Posted 2016-10-29T18:41:41.303

Reputation:

2You could use multiplication. – ckjbgames – 2017-01-24T01:52:35.880

1

SmileBASIC, 20 bytes

FOR I=1TO 1E100?NEXT

12Me21

Posted 2016-10-29T18:41:41.303

Reputation: 6 110

1

.COM, 21 bytes

0000h: 83 FC 9A 74 0B B9 10 27 51 E8 F4 FF 59 E2 F9 C3
0010h: B4 02 CD 21 C3                                 

    org 100h
f:  cmp sp, -2-4*25
    jz g
    mov cx, 10000
r:  push cx
    call f
    pop cx
    loop r
    ret
g:  mov ah, 2
    int 33
    ret       

l4m2

Posted 2016-10-29T18:41:41.303

Reputation: 5 985

1

C# - 127 123 98 bytes

using System;using b=Numerics.BigInteger;void f(){for(b n=b.Pow(10,100);n-->0;)Console.Write(0);}}

Prints 10^100 copies of 0.

Yytsi

Posted 2016-10-29T18:41:41.303

Reputation: 3 582

You can golf it by 1 byte by changing n>0;n-- to n-->0;. +1 for the rest. :) – Kevin Cruijssen – 2016-10-31T14:53:57.907

@KevinCruijssen I can also save bytes by turning this into a shorter function, since OP didn't mention "full program". Thanks! :) – Yytsi – 2016-10-31T17:07:33.760

Also you can change your using to using b= System.Numerics.BigInteger and use the alias in the rest of the code – None – 2016-11-03T22:13:58.740

This should work using System;using b=Numerics.BigInteger;void f(){for(b n=b.Pow(10,100);n-->0;)Console.Write(0);}} for 98 bytes. :) – None – 2016-11-03T22:23:03.750

@Phaeze Thanks! Haven't even edited the previous edit in yet, but will do today :) – Yytsi – 2016-11-04T04:46:55.357

1

Python 2, 35 bytes

Under more realistic programming circumstances, Python allows you to multiply strings by a number, as with 'x' * 100, which would produce a string that's a hundred characters long and composed of nothing but the letter x.

However, it appears that Python string objects don't appreciate having indices whose values exceed the maximum of int. Python is content to re-cast large int values to a special bignum sort of thing, but the longest string that Python can handle is on the order of several gigabytes, and assuming each character in Python is 1 byte, it would take much, much more memory to contain the string that would unfold from 'x'*10**100.

As such, Python's built-in arbitrary arithmetic and the humble while loop allow us to produce a more practical program, which spits out one x per line for a googol lines. Thankfully, this proves to be shorter than the admittedly more readable for x in xrange(10**100):, as range() and xrange() are both limited to the largest possible value for a C long type, which is Python's native non-bignum int.

i=0
while i<10**100:
    print'x';i+=1

James Murphy

Posted 2016-10-29T18:41:41.303

Reputation: 267

i=10**100 newline while i:print;i-=1 prints googol newlines and is 7 bytes shorter – FlipTack – 2016-10-30T11:03:31.157

It's also am exact copy of someone else's solution, so I'll leave it as is. – James Murphy – 2016-10-30T12:32:30.500

If I'm right, it's an exact copy of @FlipTack program. – None – 2017-01-23T23:39:26.420

1

Common Lisp, 33

(dotimes(i(expt 10 100))(terpri))

Print newlines.

coredump

Posted 2016-10-29T18:41:41.303

Reputation: 6 292

1

Swift 3, 55 bytes

Dependency: Foundation for pow(73 bytes if you count import statement)

stride(from:0,to:pow(10,100),by:1).map{_ in print(1)}

I know there is another answer above. However, pow(10,100.0) generates error message: fatal error: Double value cannot be converted to Int because the result would be greater than Int.max, and it also requires Foundation as well

Apollonian

Posted 2016-10-29T18:41:41.303

Reputation: 61

3Yes, necessary imports are always counted. – cat – 2016-10-30T21:08:11.593

1

Clojure, 36 bytes

(doseq[i(range(.pow 100M 50))](prn))

Using java interlop cuts it down from original (reduce *'(repeat 10 100)) since clojure core does not have exponent. dotimes can only work with longs as was pointed out in comment, sadly; I had to resort to lazy seq (+5 bytes).

Michael M

Posted 2016-10-29T18:41:41.303

Reputation: 101

dotimes requires long as a parameter doesn't it? – cliffroot – 2016-10-31T10:12:01.483

It works with any N that returns TRUE for (number? N), rounding or dropping fractions when needed. – Michael M – 2016-10-31T11:33:44.703

https://goo.gl/xjwj0e it casts it to long. it agrees with the results that I get when I try to run your code, it fails with IllegalArgumentException trying to cast that number to long – cliffroot – 2016-10-31T11:41:11.693

1You are right, I had an overwritten core dotimes with some math package. I will edit with something that works in a moment. – Michael M – 2016-10-31T11:54:58.520

1

Common Lisp, 37 bytes

(loop repeat(expt 10 100)do(print'x))

Nothing fancy. Print X followed by newline 10^100 times.

MatthewRock

Posted 2016-10-29T18:41:41.303

Reputation: 913

1

Sed + bash, 107 bytes

sed "s/Z/\;done/g;s/\([A-L]\)/\1=n\;while((\1--))\;do /g"<<<"n=10;An=10**9;BCDEFGHIJKLpwdZZZZZZZZZZZZ"|bash

By removing the "|bash" at the end, you can see that the bash script generated (with newlines added for readability) is

n=10;A=n;while((A--));do n=10**9;B=n;while((B--));do C=n;while((C--));do
D=n;while((D--));do E=n;while((E--));do F=n;while((F--));do G=n;while((G--));do
H=n;while((H--));do I=n;while((I--));do J=n;while((J--));do K=n;while((K--));do
L=n;while((L--));do pwd;done;done;done;done;done;done;done;done;done;done;done;
done

which is similar to my original bash solution, below, except that it runs 11 loops of 10^9 nested in one loop of 10, for a total of 10^100 iterations. It never uses a value greater than 10^9, which fits in 32 bits. Each output line is generated with the shell builtin "pwd" instead of "echo", to save a byte.

Tested by changing 10**9 to "2" or "3" and verifying that the script generates 10 * N^11 lines.

Bash, 312 bytes

n=2*10**9
a=9765625;while((a--));do
b=n;while((b--));do c=n;while((c--));do d=n;while((d--));do e=n;while((e--));do
f=n;while((f--));do g=n;while((g--));do h=n;while((h--));do i=n;while((i--));do
j=n;while((j--));do k=n;while((k--));do echo "Hello, World!"
done;done;done;done;done;done;done;done;done;done;done

(2*10^9)^10 * 9765725 is exactly one googol.

This needs no memory because it doesn't store anything other than the 11 counters and one copy of the "Hello, World!" string. The counters are integers that never exceed 32 bits.

Unfortunately I couldn't find a way to do this with a recursive function.

Glenn Randers-Pehrson

Posted 2016-10-29T18:41:41.303

Reputation: 1 877

1

LiveCode, 83 bytes

on g c
   if c=100 then
      put 1 after fld 1
   else
      repeat 10
         g c+1
      end repeat
   end if
end g

Logically pretty straightforward, but validated by changing the test value for c. Set it to 1, you get ten 1's. Set it to 2, you get 100. Set it to 3 you get 1,000, etc.

LiveCode automatically formats with leading spaces, but it's not required for the code to work.

The argument c will default to empty, and in LiveCode it's perfectly fine to add 1 to empty (and results in 1).

LiveCode can write to stdout, but it's a visual environment and putting text into a field is more common.

Geoff Can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of.

It's a beeping massive binary counter: 333 bits are needed to express 1 googol, so there are 333 half-adders @ and 333 registers Z. (Actually only 100/log10(2) = ~332.2 bits are required, but this solution can't take advantage of those massive savings). There are also a few periodic caches K, which are required for this to even run correctly.

Note about the TIO: instead of using -w (which is a fake stdin consisting of infinite null bytes), it uses regular input. The result is that it terminates at the end of input, rather than attempting to outlive the universe by a factor of 1080.

The termination condition is encoded by the presence or absence of ~ near the Zs. If you worked from the bottom up, writing a '1' when you see a ~, and '0' when you don't, you'll have the binary representation for 1 googol.

Here is a TIO that only prints 100 times. This one does use -w, showing off the termination condition.

Also scattered around are *a, *e, and *f. These work together to produce an ASCII '1' for the output. If they were absent, null characters would be printed instead.

Phlarx

Posted 2016-10-29T18:41:41.303

Reputation: 1 366

0

cQuents, 11 bytes

"#10^100::0

Given enough time (and memory, although it times out on TIO instead of running out of output space), will print 10^100 copies of whatever is to the right of 0.

Explanation

"             No join on output
 #10^100      Set n to 10^100
        ::    Print the sequence from 1 to n
          0   Each item in the sequence is 0

Try it online!

Stephen

Posted 2016-10-29T18:41:41.303

Reputation: 12 293

Note current version uses & instead of ::, saving 1 byte – Stephen – 2019-02-01T04:54:41.823

0

HadesLang, 3153 bytes

I know this is really bad...but at least I tried, right?

for[num a in range:[0,99]]
for[num b in range:[0,99]]
for[num c in range:[0,99]]
for[num d in range:[0,99]]
for[num e in range:[0,99]]
for[num f in range:[0,99]]
for[num g in range:[0,99]]
for[num h in range:[0,99]]
for[num i in range:[0,99]]
for[num j in range:[0,99]]
for[num k in range:[0,99]]
for[num l in range:[0,99]]
for[num m in range:[0,99]]
for[num n in range:[0,99]]
for[num o in range:[0,99]]
for[num p in range:[0,99]]
for[num q in range:[0,99]]
for[num r in range:[0,99]]
for[num s in range:[0,99]]
for[num t in range:[0,99]]
for[num u in range:[0,99]]
for[num v in range:[0,99]]
for[num w in range:[0,99]]
for[num x in range:[0,99]]
for[num y in range:[0,99]]
for[num z in range:[0,99]]
for[num A in range:[0,99]]
for[num B in range:[0,99]]
for[num C in range:[0,99]]
for[num D in range:[0,99]]
for[num E in range:[0,99]]
for[num F in range:[0,99]]
for[num G in range:[0,99]]
for[num H in range:[0,99]]
for[num I in range:[0,99]]
for[num J in range:[0,99]]
for[num K in range:[0,99]]
for[num L in range:[0,99]]
for[num M in range:[0,99]]
for[num N in range:[0,99]]
for[num O in range:[0,99]]
for[num P in range:[0,99]]
for[num Q in range:[0,99]]
for[num R in range:[0,99]]
for[num S in range:[0,99]]
for[num T in range:[0,99]]
for[num U in range:[0,99]]
for[num V in range:[0,99]]
for[num W in range:[0,99]]
for[num X in range:[0,99]]
for[num Y in range:[0,99]]
for[num Z in range:[0,99]]
for[num aa in range:[0,99]]
for[num ba in range:[0,99]]
for[num ca in range:[0,99]]
for[num da in range:[0,99]]
for[num ea in range:[0,99]]
for[num fa in range:[0,99]]
for[num ga in range:[0,99]]
for[num ha in range:[0,99]]
for[num ia in range:[0,99]]
for[num ja in range:[0,99]]
for[num ka in range:[0,99]]
for[num la in range:[0,99]]
for[num ma in range:[0,99]]
for[num na in range:[0,99]]
for[num oa in range:[0,99]]
for[num pa in range:[0,99]]
for[num qa in range:[0,99]]
for[num ra in range:[0,99]]
for[num sa in range:[0,99]]
for[num ta in range:[0,99]]
for[num ua in range:[0,99]]
for[num va in range:[0,99]]
for[num wa in range:[0,99]]
for[num xa in range:[0,99]]
for[num ya in range:[0,99]]
for[num za in range:[0,99]]
for[num Aa in range:[0,99]]
for[num Ba in range:[0,99]]
for[num Ca in range:[0,99]]
for[num Da in range:[0,99]]
for[num Ea in range:[0,99]]
for[num Fa in range:[0,99]]
for[num Ga in range:[0,99]]
for[num Ha in range:[0,99]]
for[num Ia in range:[0,99]]
for[num Ja in range:[0,99]]
for[num Ka in range:[0,99]]
for[num La in range:[0,99]]
for[num Ma in range:[0,99]]
for[num Na in range:[0,99]]
for[num Oa in range:[0,99]]
for[num Pa in range:[0,99]]
for[num Qa in range:[0,99]]
for[num Ra in range:[0,99]]
for[num Sa in range:[0,99]]
for[num Ta in range:[0,99]]
for[num Ua in range:[0,99]]
for[num Va in range:[0,99]]
out:1
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end

Azeros

Posted 2016-10-29T18:41:41.303

Reputation: 41

What is that supposed to be. Do you really need so many for loops. Also if possible provide a link so this can be tested / – Muhammad Salman – 2018-06-01T13:59:39.627

@Muhammad Salman Because Hades doesn't have a datatype for BigInts yet. Unfortunatly I can't provide a link to test this :/ – Azeros – 2018-06-01T14:02:07.473

Is the language stable and has it been released ? If it is you should probably have it added to TIO. Will make it a lot easier for link providing.

– Muhammad Salman – 2018-06-01T14:10:59.297

0

ForceLang, 58 bytes

set k 10.pow 100
label a
set k k+-1
io.write 1
if k
goto a

SuperJedi224

Posted 2016-10-29T18:41:41.303

Reputation: 11 342

0

Charcoal, 9 bytes

Note that Charcoal uses a custom codepage.

FX¹⁰¦¹⁰⁰D

Prints one googol newlines. Takes around 3.16887646×10⁹⁰ years to finish running.

Explanation

F        For
 X       Exponentiate
  ¹⁰¦¹⁰⁰  10, 100
D        Print (Dump) contents of canvas ("") plus newline

This will not freeze your computer (luckily!) because Charcoal has a 10ms minimum delay between prints by default. Charcoal used range as of this challenge's posting, therefore using more than 4GB of memory, but this has been fixed.

ASCII-only

Posted 2016-10-29T18:41:41.303

Reputation: 4 687

0

Dip, 8 bytes

TT*T^(¹p

Prints googol newlines.

Explanation:

TT       # Pushes 10 twice
             # Stack: [10, 10]
  *      # Multiply 10 by 10
             # Stack: [100]
   T     # Push 10
             # Stack: [100, 10]
    ^    # Raise 10 to 100
             # Stack: [Googol]
     (   # Do Googol times
             # Stack: []
      ¹  # Push ""
             # Stack: [""]
       p # Print
             # Stack: []

Better version that puts to use some features released after this challenge: (4 bytes)

UX(q

Explanation:

U    # Push 100
         # Stack: [100]
 X   # Raise 10 to 100
         # Stack: [Googol]
  (  # Repeat Googol times
         # Stack: []
   q # Print a newline
         # Stack: []

Oliver Ni

Posted 2016-10-29T18:41:41.303

Reputation: 9 650

0

05AB1E, 8 bytes

TTT*mFõ,

Prints googol newlines.

Try it online! (Not recommended)

Explanation:

TTT      # Push 10 three times
             # Stack: [10, 10, 10]
   *     # Multiply 10 by 10
             # Stack: [10, 100]
    m    # Raise 10 to 100
             # Stack: [Googol]
     F   # Do Googol times
             # Stack: []
      õ  # Push ""
             # Stack: [""]
       , # Print
             # Stack: []

Oliver Ni

Posted 2016-10-29T18:41:41.303

Reputation: 9 650

Not recommended? More like won't run. – Magic Octopus Urn – 2017-01-23T17:46:55.987

0

PHP7 (64-bit), 36 bytes

<?=bcsub(bcpow(10,bcpow(10,100)),1);

Should output 10^(10^100)-1 so 10^100 times the digit 9.

As of PHP 7.0.0, there are no particular restrictions regarding the length of a string on 64-bit builds. Source

Crypto

Posted 2016-10-29T18:41:41.303

Reputation: 862

I don't think there's enough RAM in the entire universe to complete this operation. I tried with only 1e10 and it stopped after it had allocated 5 GB and then tried to allocate 18.4 exabytes. I gave it 10GB, so I was a bit short :) – aross – 2016-11-01T10:15:40.673

0

VBA 117 bytes

Sub q():Dim x(100):While x(100)=0:Debug.Print:x(0)=x(0)+1:i=0:While x(i)>9:x(i)=0:i=i+1:x(i)=x(i)+1:Wend:Wend:End Sub

Invoke with q. Prints a googol newlines to immediate window. Easy to test by changing the "While x(100)" to say "While x(2)", which prints a hundred newlines.

I could use "MsgBox 0" in place of "Debug.Print" (saving 3 characters) but that would involve pressing return on the output more times than feasible, countering the whole idea of "program".

Joffan

Posted 2016-10-29T18:41:41.303

Reputation: 832