35
\$\begingroup\$

Let us take a break from the brain-wrecking questions and answer some of the simpler ones

You have recently read something extremely funny, and want to express your laughter to the world! But how can you?

Task

You have to display the string: Lolololololololololololololololololololololololololololololololololololololololololololololololololololololololol...

...to STDOUT.

The string should be of infinite length, or will constantly be printed until the end of time.

It is just as simple!

But remember, this is code-golf, so the source code must be as short as possible!

Note: Some languages may throw errors since excecution can be timed out, or for other reasons. That is okay! It can be weird when you laugh forever!


Good luck!

\$\endgroup\$
11
  • 2
    \$\begingroup\$ By the way, standard site rules will allow functions which return the result (e.g. in an infinite generator) making the print to STDOUT part redundant unless you specify that this must be a full program (which I'd advise against, but is allowed). \$\endgroup\$ Sep 12, 2020 at 13:21
  • 5
    \$\begingroup\$ Possible duplicate of Scream very loudly \$\endgroup\$ Sep 12, 2020 at 14:38
  • 4
    \$\begingroup\$ I don't understand why this was closed. The other challenge is much simpler. \$\endgroup\$ Sep 12, 2020 at 19:28
  • 6
    \$\begingroup\$ @thedefault. I don't understand your comment. The difference (requires an extra character to be outputted before the program, and outputs two characters instead of one) is fairly trivial. As you can see, if we remove the print L part and change ol to A, we get an SVL answer! \$\endgroup\$
    – null
    Sep 13, 2020 at 11:56
  • 13
    \$\begingroup\$ I have reopened this question. I believe the small difference presents interesting golfing opportunities in some languages and, furthermore, that simply porting a solution might well not be competitive. One only needs to look at a few of the answers to see some interesting differences. If people disagree then by all means vote to close again. \$\endgroup\$ Sep 24, 2020 at 8:27

97 Answers 97

1 2 3
4
1
\$\begingroup\$

A0A0, 51 49 bytes

P76
A0A0
A0C3G1G1A0
A0P111P108A0
A0A1G-3G-3A0
G-3

P76 prints a 'L' (ascii code 76), after which the code enters an infinite loop. In this loop, the following code is executed.

P111 P108
P111      ; prints 'o' (ascii code 111)
     P108 ; prints 'l' (ascii code 108)

This prints "ol" infinitely, producing the rest of the infinite output.

Edit: It turns out that the loop does not have a required minimum of three instructions, which allows us to drop a no-op, saving two bytes.

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

Barrel, 8 bytes

L#∞(ol

Implicitly prints L, then infinitely loops over implicitly printing ol. The parenthesis makes o and l into one statement, since a loop can only execute one statement. (In barrel, parentheses are self-closing.)

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

Lua, 31 bytes

u=io.write u"L"::x::u"ol"goto x

Try it online!

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

GForth 30 bytes

: A ." L" 0 1 do ." ol" loop ;
\$\endgroup\$
0
0
\$\begingroup\$

Batch (30 Bytes)

@ECHO OFF
ECHO L
:a
ECHO ol
GOTO :a

If you're willing to ignore @ECHO OFF, then it's 25 bytes instead.

\$\endgroup\$
1
  • 1
    \$\begingroup\$ You could get rid of @echo off without printing echo stuff by prefixing each line (except :a) with @s. Plus, as an alternative solution, you can output without newline by doing set/p=Text to output<nul \$\endgroup\$
    – FZs
    Aug 19, 2021 at 12:04
0
\$\begingroup\$

Arduino, 82 bytes

void setup(){Serial.begin(300);Serial.print("L");}void loop(){Serial.print("ol");}

Arduino nicely splits our program into a "run once" section and a "run forever" section already.

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

Thue, 35 bytes

L::=~L
()::=(ol)
ol::=~ol
::=
(oLl)

Here is a Thue interpreter that works for this challenge. Paste the code into the box, click Update, and then click Step repeatedly (note that clicking the Run button will lock up your web browser).

Try It Online has a Thue interpreter, but it adds a newline after each print and therefore doesn't match the output format of this challenge.

Explanation

The program consists of an initial string (oLl) and three rules for transforming it. The rules are applied non-deterministically: any time a rule can be applied to the current string, it may be applied. To achieve predictable behavior, we need to design the string and the rules such that only one of them can be applied at any given point.

Thus, when the string is in its initial state (oLl), the only rule that applies is the first one:

L::=~L

This means "delete L from the string and output L."

Now the string looks like (ol), and the third rule applies:

ol::=~ol

This means "delete ol from the string and output ol."

The string is now (), at which point the second rule applies:

()::=(ol)

This means "replace () in the string with (ol)." Now the string is (ol) again, rule 3 applies again, and we continue ad infinitum.

\$\endgroup\$
1 2 3
4

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.