25
\$\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\$ – Jonathan Allan Sep 12 '20 at 13:21
  • 5
    \$\begingroup\$ Possible duplicate of Scream very loudly \$\endgroup\$ – The Fourth Marshal Sep 12 '20 at 14:38
  • 3
    \$\begingroup\$ I don't understand why this was closed. The other challenge is much simpler. \$\endgroup\$ – the default. Sep 12 '20 at 19:28
  • 5
    \$\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
  • 10
    \$\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\$ – Jonathan Allan Sep 24 '20 at 8:27

59 Answers 59

16
\$\begingroup\$

Python 3, 32 bytes

x='L'
while[print(end=x)]:x='ol'

Try it online!

In Python 3, the print function by default has end='\n' to put a newline after what you print. Rather than changing that to the empty string, we stick the value x that we want to be printed there, and don't provide any value to be printed.

We stick the printing in the while loop condition. Since print returns None by default but this is Falsey and won't continue the loop, we wrap it in a singleton list to make it Truthy.

I had tried to stick an infinite iterator into print like print(*iter(...),sep=''), but it looks like Python will consume the whole iterable first and never actually print.

\$\endgroup\$
2
  • 1
    \$\begingroup\$ I wonder why I didn't think of this when I put the printing in the condition in my Jelly answer :/ \$\endgroup\$ – Jonathan Allan Sep 12 '20 at 14:11
  • \$\begingroup\$ Ruby, 23 bytes - x='L';x='ol'while $><<x (Can't post because it's marked as duplicate. Nice trick!) \$\endgroup\$ – DrQuarius Sep 13 '20 at 4:39
14
\$\begingroup\$

Befunge-98 (PyFunge), 8 bytes

"loL",<,

Try it online!

How?

Lo:
Initially the IP is going east.
"loL" pushes l, o and L to the stack.
, prints L, < turns the IP west and , prints o.

lo forever:
The IP is now moving west.
"loL" pushes L, o and l to the stack.
The IP wraps around and ,<, prints l and o.
L is left on the stack, but since we usually assume infinite resources, this is fine.

\$\endgroup\$
10
\$\begingroup\$

brainfuck, 41 40 bytes

-1 byte thanks @ovs

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

Try it online!

\$\endgroup\$
7
  • 1
    \$\begingroup\$ You don't the initial >, at least for the interpreter you linked, since it uses a wrapping tape. \$\endgroup\$ – ovs Sep 12 '20 at 16:56
  • 2
    \$\begingroup\$ Thanks i didn't know that. \$\endgroup\$ – RezNesX Sep 12 '20 at 17:00
  • 3
    \$\begingroup\$ I found a shorter version using KSab's bfbrute: Try it online! \$\endgroup\$ – ovs Sep 12 '20 at 18:36
  • \$\begingroup\$ @ovs Do you have any tips on how to use bfbrute. \$\endgroup\$ – RezNesX Sep 12 '20 at 18:56
  • 1
    \$\begingroup\$ @JoKing the bfbrute result I commented is 30 bytes long. \$\endgroup\$ – ovs Sep 24 '20 at 15:54
10
\$\begingroup\$

x86-16 machine code, IBM PC DOS, 13 10 bytes

00000000: b04c cd29 0c20 3403 ebf8                 .L.). 4...

Listing:

B0 4C       MOV  AL, 'L'        ; start off with capital L
        PRINT:
CD 29       INT  29H            ; write to console
0C 20       OR   AL, 20H        ; lowercase it
34 03       XOR  AL, 3          ; swap between 'l' (0x6c) and 'o' (0x6f)
EB F8       JMP  PRINT          ; loop forever

Try it online!

A standalone PC DOS executable COM program. Output to console.

-3 bytes thx to @nununoisy's very clever use of XOR to swap between l and o.

Runtime:

enter image description here

Forever and ever...

\$\endgroup\$
2
  • \$\begingroup\$ 10 bytes: B0 4C mov al, 'L' PRINT: CD 29 int 29h 0C 20 or al,0x20 34 03 xor al,3 EB F8 jmp PRINT \$\endgroup\$ – nununoisy Sep 23 '20 at 21:13
  • 1
    \$\begingroup\$ @nununoisy oh that's very clever! Updated with credit given! \$\endgroup\$ – 640KB Sep 23 '20 at 21:32
9
\$\begingroup\$

Labyrinth, 7 bytes

762
8.3

Try it online!

Adds 623 % 256 == 111 to the previous answers below.

76   Push 76 and turn right (three-way junction)
.    Pop and print % 256 as char (L)
     Now the top is 0, so it should go straight, but instead it reflects to North
623  Turn right at 6 and push 623, going around the corners
.    Pop and print % 256 as char (o); go straight (three-way junction)
876  Push 876
     Loop forever, printing "lo"

10 bytes

76
8.1
 11

Try it online!

Same idea, but using 876 % 256 == 108. Turns out that going from an uppercase to lowercase is just a matter of prepending a 8 because 800 % 256 == 32. At the center junction, the top is always 0 right after pop and print, so the IP goes straight (first from north to south, and second from east to west). All the numbers are corners which turn the IP 90 degrees, so the overall path is infinity-shaped 76.111.876.111. .... This form is one byte shorter than the naive square loop:

11 bytes

76.
8 1
.11

Try it online!


14 bytes

 7
.63
1 1
11.

Try it online!

How it works

First, the flow: the execution starts at the first valid command, which is 7 on top. The only junction is 6, and since it causes the top of stack to be positive, the IP always turns right. It turns 180 degrees if it hits a dead end. So the sequence of commands executed in order is:

76.111.13676.111.13676.111. ...(runs indefinitely)

The stack has implicit zeros, and each of 0-9 adds that digit to the end of the top of the stack (in other words, n changes the top number x to 10x + n). So the program is supposed to print the characters with charcode 76, 111, 13676, 111, 13676, ...

But 13676 is not l! Actually, Labyrinth's character output is done modulo 256.

How did I find such a number? With the path designed like this

 7
.6?
1 ?
11.

The problem is to find a number ??676 that is same as l (108) modulo 256. Note that, the equation ??xxx == yyy modulo 256 (x and y are givens and ?s are unknown) is solvable if xxx == yyy modulo 8, and if so, it always has a solution within two or fewer digits, in particular 0 <= ?? < 32. Since 676 % 8 == 108 % 8 == 4, this is solvable, and the solution here is 13.

\$\endgroup\$
7
\$\begingroup\$

Python 3,  37  34 bytes

-3 thanks to xnor - noting that print may have no unnamed argument!

x='L'
while x:x=print(end=x)or'ol'

Try it online!

\$\endgroup\$
1
  • 2
    \$\begingroup\$ Nice assignment trick! You can do print(end=x). \$\endgroup\$ – xnor Sep 12 '20 at 13:39
7
\$\begingroup\$

Bash + coreutils, 23 bytes

(echo L&yes)|tr "
y" ol

Try it online!

Explanation

We can generate infinite output using yes: without arguments, it outputs an infinite stream of y separated by newlines. echo L & yes outputs an L first, so our output stream looks like

L
y
y
y
y

To turn this into the output we want, we just need to change newline to o and y to l. tr "\ny" ol does this transliteration, and we can save a further byte by using an actual newline in place of \n.

\$\endgroup\$
1
  • 1
    \$\begingroup\$ Although '\ny' is longer, you can use \\ny for the same byte count. \$\endgroup\$ – Neil Oct 18 '20 at 18:08
6
\$\begingroup\$

Marbelous, 14 31 bytes

6C
6F@0
@0/\4C

Marbelous is a language based on marble machines

  • @n (n from 0 to Z) is a portal which teleport the marble to another portal with the same value
  • 00-FF initiate a marble with this value
  • /\ create a duplicate passing marble to it's left and right
  • .. is a noop
  • marbles going out of the machine from the bottom are implicitly outputed

interpretor

-17 bytes thanks to DLosc

\$\endgroup\$
2
  • \$\begingroup\$ I think this three-line version should work: 6C, 6F@0, @0/\4C (14 bytes). I'm not 100% sure because I tried running Marbelous by putting the source code into Try It Online's Python 2 interpreter, where it seemed oddly nondeterministic--sometimes it just output L, sometimes Loo, sometimes Loooooo infinitely, and sometimes Lololololol infinitely. But since your original code did the same things, I'm reasonably confident the golfed version works correctly. \$\endgroup\$ – DLosc Sep 25 '20 at 0:05
  • \$\begingroup\$ @DLosc you're right it works, thank :D \$\endgroup\$ – jonatjano Sep 25 '20 at 7:05
6
\$\begingroup\$

Hexagony, 5 bytes

L;o>l

Try it online!

Hexagony golfing language confirmed

For some reason I was looking at my own answer that prints "six" in 6 bytes and randomly thought "what if I remove @?", and exactly got this answer. 4 bytes is impossible because Lol; is already 4 bytes and it is impossible to alternate two chars and print both in a single loop without redirection.

Since there is no "halt" command in this program, the program flow looks like this: (It is recommended to read the docs on how > redirects the PC)

 A B
C > D
 E F

    [.....................................]  <= looping region
A B C > C B A D > A D B F > F C E A > D E F C > C ...
L ; o   o ; L l   L l ; .   . o . L   l . . o   o
^ ^     ^ ^         ^ ^

After the initial L;, o; and l; appear in the big loop in that order, therefore printing Lololol....

\$\endgroup\$
5
\$\begingroup\$

Jelly, 7 bytes

”L⁾olȮ¿

A full program which prints an L then repeatedly prints ol.

Try it online!

How?

”L⁾olȮ¿ - Main Link: no arguments
”L      - set the left argument to 'L'
      ¿ - while...
     Ȯ  - ...condition: print & yield the left argument
  ⁾ol   - ...do: set the left argument to "ol"
\$\endgroup\$
5
\$\begingroup\$

Haskell, 13 bytes

'L':cycle"ol"

Try it online!

\$\endgroup\$
5
\$\begingroup\$

05AB1E, 8 6 bytes

ovs' far superior 6-byter:

„Lo[?l

Try it online!

Explanation:

„Lo     Push 2-char string onto stack ('lo')
   [    Begin infinite loop
    ?   Output with no newline
     l  Push lowercase of top of stack ('Lo' -> 'lo')
        (Implicitly close infinite loop)

05AB1E, 8 bytes

My pitiful 8-byter:

'L?„ol[?

Try it online!

It might still be golfable, perhaps if there's a way to compress 'Lol' even further.

Explanation:

'L        Push 'L' onto stack
  ?       Print without newline ('L')
   „ol    Push 2-char string onto stack ('ol')
      [   Loop Forever
       ?  Print without newline ('ol')
          (Implicitly close infinite loop)
\$\endgroup\$
3
  • \$\begingroup\$ Ah of course, How could I have missed that. Thank you! \$\endgroup\$ – Bismarck71 Sep 24 '20 at 11:48
  • \$\begingroup\$ Generally, low length strings are too much of a hassle to compress without sacrificing golfiness. \$\endgroup\$ – Razetime Sep 25 '20 at 2:44
  • 1
    \$\begingroup\$ My idea was „olÞ'Lš, good job! \$\endgroup\$ – Makonede May 10 at 17:39
4
\$\begingroup\$

Pyth, 8 bytes

p\L#p"ol

Try it online!

Explanation

p\L#p"ol
p\L        : print "L"
   #       : while True:
    p"ol   :     print "ol"
\$\endgroup\$
4
\$\begingroup\$

Keg, 5 bytes

L,{ǪȽ

Try it online!

Finally! A reasonable use for the push'n'print commands!

Explained

  • Print the letter "L" (L,)
  • While true: ({)
  • ---- Print the letter "o" (Ǫ)
  • ---- Print the letter "l" (Ƚ)
\$\endgroup\$
2
  • 2
    \$\begingroup\$ There's a push and print command for every letter?! \$\endgroup\$ – Razetime Sep 26 '20 at 5:33
  • 4
    \$\begingroup\$ @Razetime yep.... It's a result of Bad Choices™ \$\endgroup\$ – lyxal Sep 26 '20 at 6:13
4
\$\begingroup\$

Poetic, 147 bytes

haha l-o-l funny!i saw a thingy,it was soo funny
o?what
i am crying
o?what
i am dying,literal CHOKING
dying r-n?goddamn
just see
ohhhhhh heh,lol ig

Try it online!

In the form of a text conversation between two people collectively laughing at something they found online.

\$\endgroup\$
4
\$\begingroup\$

Vyxal 5, 9 bytes

\L₴{`ol`₴

Try it Online!

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

MATLAB/Octave, 38 35 33 31 bytes

-2 bytes thanks to flawr -2 bytes thanks to tsh

"L";while fprintf(ans);"ol";end

Try it online!
In MATLAB the output in GUI command window is truncated, but the code itself executes forever. Maybe if you run script from actual command prompt it will actually display new ols infinitely. Dunno, didn't try. Online Octave implementations I tried (tio.run & octave-online.net) obiously kill the execution of script at some point.
Also, if you decide to run this in MATLAB, use Ctrl+C to stop, because clicking Pause won't do anything.

\$\endgroup\$
2
  • 1
    \$\begingroup\$ Nice, you can shorten it a little bit using x="L";while fprintf(x);x="ol";end \$\endgroup\$ – flawr Sep 25 '20 at 20:12
  • 1
    \$\begingroup\$ "L";while fprintf(ans);"ol";end is shorter \$\endgroup\$ – tsh May 11 at 10:19
3
\$\begingroup\$

Labyrinth,  29  26 bytes

7 :::.:+
6 1  # #
.11  -:.

Try it online!

How?

Labyrinth starts with the instruction pointer at the top left and executes the character underneath, performing actions on the top of the main stack (and an auxiliary stack, not used here). After executing an instruction the instruction pointer then moves in a direction which is dependent on how many neighbouring instructions there are (spaces are not instructions) and the value of the top of the main stack. As such this code does the following:

7 - pop (implicit 0), multiply by 10 and add seven    main stack: [7]
6 - pop (y), multiply by 10 and add six                           [76]
. - pop (76), print that byte ('L')                               []
1 - pop (implicit 0), multiply by 10 and add one                  [1]
1 - pop (1), multiply by 10 and add one                           [11]
1 - pop (11), multiply by 10 and add one                          [111]
: - duplicate the top of the main stack                           [111,111]
: - duplicate the top of the main stack                           [111,111,111]
: - duplicate the top of the main stack                           [111,111,111,111]
. - pop (111), print that byte ('o')                              [111,111,111]
    three neighbours (::#), positive top of main -> turn
# - push depth of main stack                                      [3,111,111,111]
- - pop (b=3), pop (a=111), subtract (a-b=108), push              [108,111,111]
: - duplicate the top of the main stack                           [108,108,111,111]
. - pop (108), print that byte ('l')                              [108,111,111]
# - push depth of main stack                                      [3,108,111,111]
+ - pop (b=3), pop (a=108), add (a+b=111), push                   [111,111,111]
: - duplicate the top of the main stack                           [111,111,111,111]
. - pop (111), print that byte ('o')                              [111,111,111]
    three neighbours (::#), positive top of main -> turn
# - ...now we will continue to print 'l' then 'o' ad-infinitum
\$\endgroup\$
4
  • 1
    \$\begingroup\$ 14 bytes using 13676%256 == 108. \$\endgroup\$ – Bubbler Sep 24 '20 at 3:38
  • \$\begingroup\$ That's really neat, don't you want to post it yourself? \$\endgroup\$ – Jonathan Allan Sep 24 '20 at 8:17
  • \$\begingroup\$ Unfortunately the question was closed as duplicate... \$\endgroup\$ – Bubbler Sep 24 '20 at 8:18
  • 1
    \$\begingroup\$ I've reopened the question and commented about why under the question. \$\endgroup\$ – Jonathan Allan Sep 24 '20 at 8:28
3
\$\begingroup\$

Husk, 7 bytes

:'L¢"ol

Try it online!

Commented:

:         -- prepend
 'L       -- the character L
   ¢      -- to the infinitely repeated
    "ol"  -- string "ol" (closing quote not required)

Equivalent to this Haskell function:

(:) 'L' (cycle "ol")

Try it online!

\$\endgroup\$
3
\$\begingroup\$

x86-16 machine code MS-DOS - 23 bytes

This answer inspired by 640KB answer.

 000000: B4 02 B7 4C 8A D7 CD 21  B2 6F CD 21 8A D7 80 F2   ...L...!.o.!....
 000010: 20 CD 21 EB F3 CD 20                                .!... 

Listing:

      6 0100  B4 02              MOV AH, 02H
      7 0102  B7 4C              MOV BH, 'L'
      8 0104  8A D7              MOV DL, BH
      9 0106  CD 21              INT 21H
     10
     11 0108                 PRINT:
     12 0108  B2 6F              MOV DL, 'o'
     13 010A  CD 21              INT 21H
     14 010C  8A D7              MOV DL, BH
     15 010E  80 F2 20           XOR DL, 20H
     16 0111  CD 21              INT 21H
     17 0113  EB F3              JMP PRINT
     18
     19 0115  CD 20              INT 20H

Output:

output

\$\endgroup\$
1
  • \$\begingroup\$ The INT 20H at the end seems unnecessary. Also, MOV DL, BH (with or without the XOR DL, 20H) takes far too many bytes. Just move the constant into DH directly. Also move the PRINT: back one instruction to save yourself an INT 21H. \$\endgroup\$ – Neil Oct 18 '20 at 18:12
3
\$\begingroup\$

Flobnar, 18 bytes

og,!<
\l@>\<
2:L!_

Try it online! (requires the -i flag)

Explanation

Flobnar is a 2D language where expressions are laid out geometrically. For example, for a program that computes the number 10, you might write:

5
+  @
5

Here, @ indicates the entry point for the program, and has the effect of evaluating the term to its west; + evaluates the terms to the north and south and returns their sum; etc.

The basic idea for this program is to embed the characters 'o', 'l', and 'L' in the source code at coordinates (0, 0), (1, 1), and (2, 2) respectively. Execution proceeds roughly like this:

def step(n):
    step(!n if (!putchar(get(n, n))) else "impossible since putchar() returns 0")

step(2)

Here's what the program looks like ungolfed:

o    >>>>v
 l   ^ \ < \ @
  L    v   2
     :!_
  :
  g , !<
  :

See the specification for more detailed information about what each term does.

\$\endgroup\$
2
  • \$\begingroup\$ Note that this requires -i, so I don't think it works for the reference implementation. \$\endgroup\$ – Wezl Oct 5 '20 at 19:41
  • \$\begingroup\$ @Wezl I don't think the reference implementation even supports character IO. \$\endgroup\$ – Esolanging Fruit Oct 5 '20 at 20:05
3
\$\begingroup\$

StupidStackLanguage, 26 bytes

avqvvmifavvqimiqdddltflflu

Try it online!

\$\endgroup\$
1
  • \$\begingroup\$ This sounds like an interesting language! \$\endgroup\$ – user Sep 12 '20 at 16:40
3
\$\begingroup\$

!@#$%^&*()_+, 7 bytes

L(@o@l)

Try it online!

L(@o@l)
L          Pushes character literal 'L'
 (    )    Loop while top of stack:
  @            Output top of stack as character ('L' first iteration, 'l' otherwise)
   o@          Output 'o'
     l         Push 'l', repeating the loop
\$\endgroup\$
3
  • 1
    \$\begingroup\$ Fun fact: This language inspired me to make this challenge. In fact, the first program I wrote in !@#$%^&*()_+ was a LOLOL program (it printed the capitalized version though). Today it survives in its esolang article. \$\endgroup\$ – SunnyMoon Sep 28 '20 at 12:43
  • 1
    \$\begingroup\$ @SunnyMoon I'm honored :D What a bizarre coincidence, I haven't posted on this site in almost a year. \$\endgroup\$ – Conor O'Brien Sep 29 '20 at 2:27
  • 1
    \$\begingroup\$ Welcome back, Conor :) \$\endgroup\$ – Shaggy Sep 29 '20 at 19:39
3
\$\begingroup\$

dc, 14 bytes

76P[[ol]Pdx]dx

Try it online!

\$\endgroup\$
3
\$\begingroup\$

braingasm, 12 bytes

76.28524+[.]

Prints the byte streams 76 once, then 28524 forever

\$\endgroup\$
3
\$\begingroup\$

Golang, 53 27 bytes

print("L");for{print("ol")}

Try it online!

EDIT: Apparently package main and func main() don't necessarily count towards the byte count for Go e.g. https://codegolf.stackexchange.com/a/107159/95793.

Previous version:

package main
func main(){print("L");for{print("ol")}}
\$\endgroup\$
3
\$\begingroup\$

PHP, 24 bytes

L<?php for(;;)echo'ol';
\$\endgroup\$
2
  • 1
    \$\begingroup\$ -1 byte using a for loop. \$\endgroup\$ – Razetime Sep 28 '20 at 6:51
  • \$\begingroup\$ -2 by using ol instead of 'ol' and a for loop. \$\endgroup\$ – Makonede May 10 at 17:45
3
\$\begingroup\$

Batch, 42 40 bytes

@set/p=L<nul
:g
@set/p=ol<nul
@goto g

set/p outputs the string after the = as the prompt, and then expects to read from the console, which ends the line when you hit enter. But we redirect the input, so no enter happens, and we simply end up with a infinite series of "prompts" all on one line. Edit: Saved 2 bytes thanks to @T3RROR.

\$\endgroup\$
1
  • \$\begingroup\$ -2 bytes by changing each @set/ps= to @set/p= \$\endgroup\$ – T3RR0R May 11 at 14:43
3
\$\begingroup\$

Flipbit, 35 30 28 bytes

Thanks to Bubbler for -5 by shortening the loop

Thanks to ovs for -2 by being big smort

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

Try it online!

Prints L, gets the tape set up for l, then makes use of the fact that o and l differ by only their two least significant bits to create a short loop to print both characters repeatedly.

\$\endgroup\$
3
  • \$\begingroup\$ 30 bytes \$\endgroup\$ – Bubbler Jul 24 at 14:03
  • \$\begingroup\$ @Bubbler Thanks! I wondered if the loop could be shortened, but I couldn’t figure out how to do it. \$\endgroup\$ – Aaron Miller Jul 24 at 15:55
  • \$\begingroup\$ 28 bytes by setting up l instead of o before the loop. \$\endgroup\$ – ovs Jul 24 at 16:13
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\$

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.