30
\$\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 '20 at 13:21
  • 5
    \$\begingroup\$ Possible duplicate of Scream very loudly \$\endgroup\$ Sep 12 '20 at 14:38
  • 4
    \$\begingroup\$ I don't understand why this was closed. The other challenge is much simpler. \$\endgroup\$ Sep 12 '20 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 '20 at 11:56
  • 12
    \$\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 '20 at 8:27

78 Answers 78

1 2
3
1
\$\begingroup\$

Splinter, 11 bytes

A{\o\lA}\LA

Try it online!

Interpreter breaking version. Would run forever otherwise.

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

AWK, two answers of 33 bytes

BEGIN{for(;;)printf s=s?"ol":"L"}

and

BEGIN{for(printf"L";;)printf"ol"}

Try it online! (uncomment a line to try it)

First answer: a simple ternary condition upon the assignment of the variable s. On the first run, it is evaluated as false. As it is not assigned yet, it is parsed as a null string, which is false.

Second answer: just a for loop.

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

><>, 12 bytes

"L"v
l"o<o"o

Explanation

"L"v     // pushes the character 'L' onto the stack and moves to the second line
l"o<o"o  // after outputting the L character, enters an infinite loop of pushing "lo" and outputting both
\$\endgroup\$
1
\$\begingroup\$

Perl 5 (ppencode-cpmpatible), 87 bytes

print q pop xor print chr ord q else while length or print uc chr ord q else and s qq q

Try it online!

How it works

# NOTE: q x STR x eq ' STR '
# chr ord STR to obtain first character
   print q pop xor
   print chr ord q else
while
# default variable is initially empty string
   length or
      # print first L
      print uc chr ord q else and
      # make sure not to come here
      s qq q
\$\endgroup\$
1
\$\begingroup\$

A0A0, 51 bytes

P76
A0A0
A0C3G1G1A0
A0P111P108G1A0
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 G1
P111         ; prints 'o' (ascii code 111)
     P108    ; prints 'l' (ascii code 108)
          G1 ; no-op, required since the loop needs three instructions

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

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

Factor, 29 bytes

"L"write [ "ol"write t ] loop

Try it online!

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

COMET II ("CASLシミュレータ (CASL II 対応)" by Daytime), 28 bytes.

The leftmost column shows an address, and one word is two bytes.

0000: 7001 0000 7002 0000
0004: 1210 0012 1220 0014
0008: F000 0002 7120 7110
000C: 1210 006C 1110 0012
0010: 6400 0000 004C 006F
0014: 0002

The simulator seems to output an LF automatically every time OUT is executed, and it requires you to set a break point to see how it works by step by step.

Original CASL II assembly program (63 bytes)

A START
 OUT Z,=2
 LAD GR1,108
 ST GR1,Z
 JUMP A
Z DC 'Lo'
 END

Usage example

Run just for a few steps, as I have no ideas how to scroll back the console.

Run just for a few steps, as I have no ideas how to scroll back the console.

\$\endgroup\$
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\$

C# (50, 45, 42 bytes)

for(var a="L";;)Console.Write(a+(a="ol"));

It works by setting a variable to L, printing that variable, then setting its value to ol; infinitely repeating steps 2 and 3.

Note: Thanks to @ceilingcat and @Browncat Programs for pointing out a shorter alternatives in the comments.

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

Pxem, filename only: 11 bytes.

Uses reference implementation feature: doesn't break the loop of .w and .a when stack is empty.

L.o.wol.p.a

OR

L.z.p12ol.a

Try it online!

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

Turbo Assembler, 136 119 bytes

.model small
.code
start:
mov dl,'L'
mov ah,2
int 21h
i:
mov dl,'o'
mov ah,2
int 21h
mov dl,'l'
int 21h
jmp i
end start

Ungolfed version:

.model small
.code
start:
    mov dl, 'L'         ; move "L" character to DL register
    mov ah, 02h         ; print "L" character
    int 21h             ; interrupt
infinity_loop:
    mov dl, 'o'         ; move "o" character to DL register
    mov ah, 02h         ; print characters
    int 21h             ; interrupt
    mov dl, 'l'         ; move "l" character to DL register
    int 21h             ; interrupt
    jmp infinity_loop   ; go to "infinity_loop" label
end start

-17 bytes thanks to @Kamila Szewczyk

Lololololo[...] in action:

Lololololo[...]

\$\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 at 12:04
0
\$\begingroup\$

BrainCrash, 43 22 bytes.

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

I'll golf off later.

Try it online!

\$\endgroup\$
0
\$\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 2
3

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.