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\$
12
  • 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

122 Answers 122

2
\$\begingroup\$

Python 3, 44 bytes

print('L',end='')
while 1:print('ol',end='')

How it works: The program first prints 'L' and then infinitely prints 'ol' on a single line using the end=''.

Try it online!

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

Japt, 14 11 bytes

-3 bytes thanks to @Shaggy

OoUª'L
ß"ol

Try it online!

Explanation

OoUª'L    // Output input if it exists else 'L'
ß"ol      // Run program with input being "ol"
\$\endgroup\$
2
  • \$\begingroup\$ 11 bytes \$\endgroup\$
    – Shaggy
    Sep 12, 2020 at 22:31
  • \$\begingroup\$ Or 12 bytes if you want to avoid the overflow. \$\endgroup\$
    – Shaggy
    Sep 12, 2020 at 23:44
2
\$\begingroup\$

Powershell v5 32 Byte

while(1-ne2){Write-Host -n 'lo'}

Has someone an idea how to shorten Write-Host? Is there an alias?

New One 52 Byte

for(1){Write-Host -n 'L'
for(1){Write-Host -n 'ol'}}
\$\endgroup\$
7
  • \$\begingroup\$ The first character printed must be a capital L, the rest must be in lower-case. You can maybe answer Scream verly loudly like this. \$\endgroup\$ Sep 24, 2020 at 11:47
  • \$\begingroup\$ ...although actually there already a terser Powershell program there. \$\endgroup\$ Sep 24, 2020 at 11:49
  • \$\begingroup\$ Thanks for the hint. \$\endgroup\$ Sep 24, 2020 at 11:53
  • 1
    \$\begingroup\$ You can shorten your answer by 4 characters by removing the not equal expression: while(1){Write-Host -n 'lo'} \$\endgroup\$
    – DBADon
    Sep 24, 2020 at 14:45
  • 1
    \$\begingroup\$ 38 bytes with set-alias. 39 bytes with raw powershell \$\endgroup\$
    – mazzy
    Sep 24, 2020 at 19:37
2
\$\begingroup\$

MAWP, 10 bytes

76;["ol":]

Try it!

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

R, 26 25 bytes

cat('L');repeat cat('ol')

Try it online!

Well, this one is pretty straightforward.

−1 byte thanks to Steffan

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

Stax, 7 6 bytes

║►yü[c

Run and debug it

Explanation

.Lo{cpvW
.Lo      push two letter string "Lo"
   {   W loop forever
    c    duplicate           → ["Lo", "Lo"]
     p   print and pop       → ["Lo"]
      v  lowercase           → ["lo"]
         begin next iteration
\$\endgroup\$
2
\$\begingroup\$

Scala, 35 34 32 bytes

print("L")
while(1>0)print("ol")

Try it online!

  • -1 thanks to ovs!
\$\endgroup\$
1
  • \$\begingroup\$ 1>0 is one byte shorter than true. \$\endgroup\$
    – ovs
    Oct 20, 2020 at 13:11
2
\$\begingroup\$

SABDT, 23 bytes

pr"L";wh(0=0){pr"ol";}

Exspanded:

pr "L";
wh(0 = 0){
   pr "ol";
}

the 1st line prints "L".

the 2nd line is a while loop. 0 is a variable reference, since it has not been declared yet it starts as "", an empty string. essentially it is a while true loop.

the 3rd line prints "ol".

\$\endgroup\$
2
  • \$\begingroup\$ Welcome to the site! Would you mind providing a link to this language, so that others can check/verify your solution? \$\endgroup\$ Oct 27, 2020 at 11:17
  • \$\begingroup\$ @caird-coinheringaahing sure thing \$\endgroup\$ Oct 27, 2020 at 22:54
2
\$\begingroup\$

BRASCA, 14 12 11 bytes

-1 bytes from RezNesX

`loL`o[:mo]

Try it online!

Explanation

`loL`         - Push 'Lol' to the stack
     o        - Output the 'L'
      [:mo]   - Output the next character of ['o', 'l']
\$\endgroup\$
1
  • \$\begingroup\$ 11 bytes: `loL`o[:mo] \$\endgroup\$
    – RezNesX
    May 12, 2021 at 11:52
2
\$\begingroup\$

Fueue, 14 bytes

76):[111)108:]

Try it online!

Explanation

76 is the character code for L, 111 is the code for o, and 108 is the character code for l. This code first prints an L and then goes into an infinite loop that keeps printing out ol.

76):[111)108:]

76              Print 'L'.
  ):[        ]  Turn the stuff in the brackets into 111)108:[111)108:]
     111 108    Print 'ol'.
        )   :   Loop infinitely.
\$\endgroup\$
2
\$\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\$
1
  • \$\begingroup\$ Turbo assembler for which processor? I'm guessing Z80? \$\endgroup\$ Nov 20 at 7:44
2
\$\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\$
2
\$\begingroup\$

Canvas, 6 bytes

LWol+]

Try it here!

Constructs an infinite length string.

Explanation:
LWol+] | Full program (characters replaced for clean spacing)
-------+------------------------------------------------------
L      | Push the string "L"
 W   ] | While ToS is truthy (without popping),
  ol   |  Push the string "ol"
    +  |  Add the two strings (i.e. append "ol" to the string)
       | Print ToS (implicit) (will not ever actually occur)

Non-empty strings are always truthy in Canvas.

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

Factor, 29 bytes

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

Try it online!

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

Vyxal, 8 bytes

\L₴{‛ol₴

Try it Online!

Will add an explanation soon.

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

Pari/GP, 22 bytes

until(!L=ol,print1(L))

Try it online!


Pari/GP, 22 bytes

while(!print1(L),L=ol)

Try it online!

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

Lexurgy, 33 bytes

a propagate:
*=>ol/_ $
*=>L/$ _ o

Explanation:

a propagate: # while the input changed last iteration...
*=>ol/_ $    # append "lo" to the end of the input
*=>L/$ _ o   # prepend "L" exactly once
\$\endgroup\$
2
\$\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\$
2
\$\begingroup\$

Underload, 18 15 bytes

(L)S((ol)S:^):^

Try it online!

Prints out L, then ololololololololol...

GolFunc, 13 bytes

No interpreter yet, but you can look at the specs.

..P'L.Y.P"ol"

Explanation:

 .P'L         # print L (returns identity, so no worries)
.             # apply the result to...
     .Y       # the Y combinator applied to...
       .P"ol" # the function which prints "ol"
\$\endgroup\$
1
  • \$\begingroup\$ It's Underload!!!! \$\endgroup\$ Mar 15, 2022 at 14:30
2
\$\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\$
2
\$\begingroup\$

Lean Mean Bean Machine, 19 bytes

OOO
"""
Lol
U!!
 ~~

Try it online!

Lol

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

Zsh + jot, 23 bytes

<<<L`jot -s '' -b ol 0`

Try it online!. This times out on TIO (and crashes my Terminal app) because jot is busy printing millions of copies of 'ol' to memory before <<< gets a chance to print it. According to the spec, that's an acceptable result (and it allows me to beat the bash solution!). However here's a finite example that doesn't time out:

<<<L`jot -s '' -b ol 999`
\$\endgroup\$
1
  • \$\begingroup\$ otherwise, do printf L;jot -s '' -b ol 0 \$\endgroup\$
    – roblogic
    Mar 27 at 13:38
2
\$\begingroup\$

Flip, 10 bytes

Perfect challenge for showcasing Flip's execution model.

lang is not on ATO yet, so I'm using a makeshift one.

' L|qq'ol'

Try it online!

Explanation

'
  L         Push ord code of 'L' onto stack
   | q'ol'
    q       Print that as a character
      ' l   Push ord code 'l' onto stack
            IP goes over right bound, so mirror it
         '
       o    Push ord code 'o' onto stack
     q      Print 'o' as character
   |        Mirror the IP
    q       Print 'l' as character
            Since there's no terminating condition, this continues forever
\$\endgroup\$
1
  • \$\begingroup\$ Welcome to Code Golf, and nice answer! \$\endgroup\$ May 20 at 16:18
2
\$\begingroup\$

Taxi, 389 bytes

L is waiting at Writer's Depot.Go to Writer's Depot:w 1 l 2 r 1 l 2 l.Pickup a passenger going to Post Office.Go to Post Office:n 1 r 2 r 1 l.[L]o is waiting at Writer's Depot.l is waiting at Writer's Depot.Go to Writer's Depot:s 1 r 1 l 2 l.Pickup a passenger going to Post Office.Pickup a passenger going to Post Office.Go to Zoom Zoom:n.Go to Post Office:w 3 l 2 r 1 l.Switch to plan L.

Try it online!

First Taxi answer. Try learning Taxi, I promise that you won't regret it. This was one of the most fun challenges I've done so far.

Explained:
First of all, we go to Writer's Depot, where a string L is waiting. Then, we go back to Post Office to ship them off to STDOUT. Then, we go back to Writer's Depot to pick up string ol. With string ol, we go to Zoom Zoom to buy some fuel. We go to Post Office to print them, and then loop. Here's the problem though: we don't have enough money. We are earning less than the fuel cost. Solution? Pick up o and l as two separate passengers! That way, the both pay the fare of 0.07/mile so we can afford the 1.45/gallon fuel.

Each gallon carries them 18 miles. Based on the map, I estimate that the trip is 10 miles back and forth, and we carry them 7 miles. 10/18 = 0.55555 gallons. 0.55555 gallons costs around 0.8 dollars at Zoom Zoom. 7*0.07 is only 0.49 dollars, while 7*(0.07+0.07) for two passengers is 0.98, which leave 0.18 to spare. Profit.

Just for fun:
Say we're traveling at an average of 30 mph. Then, the trip is 20 minutes long back and forth. We can make three trips in an hour. 0.18*3 = 0.54. Townsburg Taxi Company, Inc had better be paying us! To maximize profit, we can carry three passengers at once: maybe o l and ol. This yields 2.01/hour. To maximize the maximized profit, we can carry them on longer routes. If we run all 360 miles on a full tank before dropping them off at the Post office, we can get fired and around 3.8 an hour if we plan carefully.

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

Commodore BASIC V2 (Commodore C64) 33 BASIC Bytes, 31 characters with BASIC keyword abbreviations

0?"{SHIFT+L}{CTRL+H}{CTRL+N}";:FORI=0TO1STEP0:?"OL";:NEXT

Quick explanation:

  • Printing the control characters H stops from switching between CBM Graphics mode and Business case mode (with the latter being upper and lower case characters)
  • Printing the control character N will switch to business case mode
  • Setting up a FOR/NEXT loop with a step of 0 is a continuous loop
  • Then printing the OL will be in lower case mode

Please see the screen shot for this in action.

Commodore C64 Lololol challenge

\$\endgroup\$
1
  • 1
    \$\begingroup\$ Welcome to Code Golf, and nice answer! \$\endgroup\$ May 21 at 21:44
1
\$\begingroup\$

Splinter, 11 bytes

A{\o\lA}\LA

Try it online!

Interpreter breaking version. Would run forever otherwise.

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

Lua, 31 bytes

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

Try it online!

\$\endgroup\$
2

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.