39
\$\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
  • 5
    \$\begingroup\$ I don't understand why this was closed. The other challenge is much simpler. \$\endgroup\$ Sep 12, 2020 at 19:28
  • 7
    \$\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\$ Sep 13, 2020 at 11:56
  • 15
    \$\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

116 Answers 116

1 2 3
4
1
\$\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
1
\$\begingroup\$

Haskell, 25 bytes

main=putStr$'L':cycle"ol"

To return an infinite string, only 13 bytes required:

'L':cycle"ol"
\$\endgroup\$
1
\$\begingroup\$

Z80Golf, 9 bytes

00000000: 3E 4C FF 3B 3B F6 20 EE
00000008: 03

Try it online!

Explanation

  ld a, $4C ; Load the ASCII code of "L" into a
  rst $38   ; Jump past the end of the program (print "L") and push the next address (loop) to the stack

loop:
  dec sp    ; \
  dec sp    ; _} Push the last value (the address of loop) back to the stack by moving the stack pointer by 2 downwards
  or $20    ; Switch from uppercase to lowercase (idempotent). $4C ("L") -> $6C ("l"), $6C ("l") -> $6C ("l")
  xor $03   ; Toggle A between $6C ("l") and $6F ("o")

; ... the program runs (executes NOPs) until PC = $8000 where it prints A, then returns to the address on the stack (which is always loop)
\$\endgroup\$
1
\$\begingroup\$

BrainCrash, 43 22 bytes.

^^+++++++++++.>>[.<.>]

I'll golf off later.

Try it online!

\$\endgroup\$
1
\$\begingroup\$

Gaia, 9 bytes

:p⌋
Lo”↑∞

Try it online!

The first line is a helper function which prints a copy of its input and returns its input converted to lowercase.

Lo” pushes the string "Lo" to the stack, and ↑∞ calls the above function infinitely. Leading quotation marks can be omitted at the start of a line.

The same could be done in a single line with Lo”⟨:p⌋⟩∞.

\$\endgroup\$
1
\$\begingroup\$

JavaScript (Node.js), 49 bytes

for(i=0;++i;){process.stdout.write(i<2?"L":"ol")}

Try it online!

\$\endgroup\$
1
\$\begingroup\$

APL (Dyalog Unicode), 14 bytes

{∇⍞←'ol'}⍞←'L'

Try it online!

\$\endgroup\$
1
\$\begingroup\$

Pyth, 8 bytes

p\LWp"ol

Try it online!

\$\endgroup\$
1
\$\begingroup\$

Etch, 23 bytes

do
:outnnl"lo";
forever
\$\endgroup\$
1
  • \$\begingroup\$ This looks like it outputs "lololololol", you need a capital L. \$\endgroup\$
    – emanresu A
    Aug 6, 2022 at 7:35
1
\$\begingroup\$

Befunge-98 (PyFunge), 15 12 11 bytes

'Lv
'l>,'o,

Try it online!
-3 bytes thanks to @emanresuA
-1 byte thanks to @WheatWizard

Befunge-93 compatible version (1 byte more):

L"v
, <,"ol"

Try it online!

\$\endgroup\$
4
  • \$\begingroup\$ Welcome to Code Golf, and nice first answer! Be sure to check out our Tips for golfing in Befunge page for ways you can golf your program! I think this can be 12 bytes with some rearranging. \$\endgroup\$
    – emanresu A
    Mar 17, 2022 at 19:26
  • \$\begingroup\$ @emanresuA thanks! However I can't get over the fact that your code produces Llolo... instead of Lolol... \$\endgroup\$ Mar 17, 2022 at 20:12
  • \$\begingroup\$ Oops. I was close... \$\endgroup\$
    – emanresu A
    Mar 17, 2022 at 20:17
  • \$\begingroup\$ @WheatWizard thank you too! \$\endgroup\$ Mar 18, 2022 at 0:28
1
\$\begingroup\$

Rust, 41 bytes

I know I'm a little late to the party, but I'd though I'd make a Rust contribution. Here's the code:

fn main(){print!("L");loop{print!("ol")}}

Try it online! Note that it will panic on TIO after the output exceeds 128 KiB. But it doesn't panic in my terminal!

\$\endgroup\$
1
\$\begingroup\$

PHP (25 chars)

echo'L';for(;;print'ol');
\$\endgroup\$
1
\$\begingroup\$

Clojure, 24 bytes

This is my first answer in Clojure; I only started learning it recently.

(pr 'L)(while 1(pr 'ol))

To be honest I'm not quite sure myself why (pr 'ol) works, but it does.

\$\endgroup\$
3
  • \$\begingroup\$ while 1 can be loop[] \$\endgroup\$
    – naffetS
    Mar 26 at 21:52
  • \$\begingroup\$ @naffetS That doesn't work for me. (loop[](pr 'ol)) only prints ol once before returning. \$\endgroup\$
    – Bbrk24
    Mar 26 at 22:41
  • \$\begingroup\$ Nevermind sorry, you would need (recur) \$\endgroup\$
    – naffetS
    Mar 26 at 23:41
1
\$\begingroup\$

Rust, 41 bytes

fn main(){print!("L");loop{print!("ol")}}

Try it online!

\$\endgroup\$
1
\$\begingroup\$

Alice, 10 bytes

"olL"wo~.K

Try it online!

Explanation

"olL"wo~.K
"olL"       Puts `olL` in the stack, `L` on the top
     w   K  Never ending loop
      o     Print the first element of the stack
       ~    Swap the stack
        .   Duplicate the first element of the stack
\$\endgroup\$
1
\$\begingroup\$

Thunno, \$ 8 \log_{256}(96) \approx \$ 6.58 bytes

'L[ZL"ol

Attempt This Online!

Explanation

'L        # Push the character "L"
  [       # Forever:
   ZL     #  Print top of stack with no trailing newline
     "ol  #  Push "ol" for the next iteration
\$\endgroup\$
1
\$\begingroup\$

Binary-encoded Golifcal, 13 bytes

Hexdump of binary encoding:

00 70 01 00 4c 18 1b 00 6c 18 00 6f 1d

This binary version can be convered back to a runnable program image using the Encoder included in the github repository for the language, or run directly by adding the -x flag.

Original program image:

enter image description here

Magnified 70x with RGB colors labeled: enter image description here

\$\endgroup\$
1
\$\begingroup\$

Fortran (GFortran) --cpp, 57 bytes

#define p(s)call fput(s)
p('L')
1 p('o');p('l');goto1;end

Try it online!.

I #define a macro p() to save typing call fput('x') for every letter. And good old goto is mostly harmless.

\$\endgroup\$
1
\$\begingroup\$

><>, 8 bytes

"loL"o<o

Try it online!

Port of ovs's Befunge-98 answer.

Explanation

  • The IP starts in the top-left going right.
  • "loL" pushes the characters "l", "o" and "L" to the stack
  • o outputs the current character ("L")
  • < makes the IP go left
  • o outputs the current character ("o")
  • "Lol" pushes the characters "L", "o" and "l" to the stack
  • o outputs the current character ("l")
  • (at which point we're back to <)

Old 12-byter:

"L"v
o"o>o"l
  • The IP starts in the top-left going right.
  • "L" pushes the character "L" to the stack
  • v makes the IP go down
  • > makes the IP go right
  • o outputs the current character
  • "lo" pushes the characters "l" and "o"
  • (wraps around to the start of the line)
  • o outputs the current character
  • (at which point we're back to >)
\$\endgroup\$
1
\$\begingroup\$

Nibbles, 5 bytes (10 nibbles)

"L"^~"ol"

Attempt This Online!

\$\endgroup\$
1
\$\begingroup\$

Python, 45 Bytes

print('Lo',end='')
while 1:print('lo',end='')

Try it online!
Seems ungolfable.

\$\endgroup\$
1
\$\begingroup\$

SAS, 42 bytes

SAS gives "the ultimate" answer in 42 bytes ;-)

The code:

data;put'L'@;do while(1);put'ol'@;end;run;

Human readable:

data;
  put 'L' @;
  do while(1);
    put 'ol' @;
  end;
run;
\$\endgroup\$
1
\$\begingroup\$

><> (Fish), 13 bytes

'L'o'lo'oo30.

Try it

\$\endgroup\$
1
\$\begingroup\$

Byte-based instruction jumping, 8 bytes

↑L↑o↑l,L

How it works: When executed, the instructions stored in moves the instruction pointer to the right, prints the value stored there (L) and moves to the right again, making it point to the second . the second does the same again, except o is printed instead of L, and the third prints l and makes the instruction pointer point to ,.

, also makes the instruction pointer move to the right (to the second L), but then it jumps back to the last byte with the same value as the current one (the first L), and moves right once more (to the second ). Now it ends up in an infinite loop where it moves forward, prints o, moves forward, prints l, moves forward, jumps to the first L, moves forward, prints o et cetera.

\$\endgroup\$
1
\$\begingroup\$

Basic, 20 bytes

?"L";:DO:?"ol";:LOOP

Try it online!

\$\endgroup\$
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\$
2
  • \$\begingroup\$ What does Serial.begin(300) do? \$\endgroup\$ Jun 2 at 20:31
  • \$\begingroup\$ Opens serial communications at 300 baud. 9600 is more common in practice, but it's one digit longer to write :P \$\endgroup\$
    – Bbrk24
    Jun 2 at 20:56
1 2 3
4

Your Answer

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

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