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

133 Answers 133

4
\$\begingroup\$

dc, 14 bytes

76P[[ol]Pdx]dx

Try it 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, 2020 at 20:12
  • 1
    \$\begingroup\$ "L";while fprintf(ans);"ol";end is shorter \$\endgroup\$
    – tsh
    May 11, 2021 at 10:19
4
\$\begingroup\$

><> and Gol><>, 10 bytes

"volL
:>o$

Try it online! (><>)

Try it online! (Gol><>)

How it works

"volL    Push charcodes of v, o, l, L in that order (L is at the top)
"v       End string mode
 >       and move to the second row
  o      Pop and print one char (initially L)
: o$     Infinite loop: Swap, dup, pop and print one char
\$\endgroup\$
4
\$\begingroup\$

FALSE, 13 bytes

'L,[1]["ol"]#

Try it online!

Explanation

'L, // outputs "L" character
[1] // pushes lambda which evaluates to 1 onto the stack
["ol"] // pushes lambda which prints "ol" onto the stack
#   // Executes lambda on top of stack while the lambda below it
    // does not evaluate to zero

Note: This is my first post on this site, so let me know in the comments if I did something wrong.

\$\endgroup\$
2
  • 1
    \$\begingroup\$ Welcome to Code Golf! Nice first answer! Doesn't look like you did anything wrong, the formatting and explanation are better than most of my answers :p \$\endgroup\$ Jul 26, 2021 at 19:02
  • \$\begingroup\$ @Redwolf Programs Thanks for your feedback! Have a nice day! \$\endgroup\$ Jul 26, 2021 at 19:09
4
\$\begingroup\$

WedgeScript, 9 bytes

'Lo|"ol"o

Explanation:

'L         Pushes the character literal L to the stack
o          Output 
|          Loop the rest of the code infinitely
"ol"       Push the string "ol" to the stack
o          Output

Yes, Wedgescript is a custom language made by me, here is the repo with interpreter install instructions: github.com/WedgeScript/WedgeScript

\$\endgroup\$
1
  • \$\begingroup\$ Welcome to Code Golf! I've cleaned up the formatting of your answer a bit to make it easier to read the explanation. This language looks really cool! I think I might have to check it out! \$\endgroup\$ Aug 5, 2021 at 20:55
4
\$\begingroup\$

BitCycle, 30 bytes

v001000<   ~010!

~1011000110^

Try it online!

Outputs as a stream of bits.

\$\endgroup\$
1
  • \$\begingroup\$ 30 bytes while still avoiding the undefined behaviour of outputting two bits at the same time \$\endgroup\$
    – Jo King
    Aug 18, 2021 at 16:19
4
\$\begingroup\$

Minim, 41 39 Bytes

New solution prepends 3 to the string, saving 2 bytes:

[]=3&"loL".$<[[0]--].[0]=[0]?[0]:2.C=0.

With whitespace and comments:

[] = 3 & "loL".      ; Inserts the value 3, and the string "Lol" backwards, into \
                       memory from index 0
$< [[0]--].          ; Prints the value at the index stored at index 0 as unicode, \
                       and decrements index 0
[0] = [0] ? [0] : 2. ; Sets index 0 back to 2 if it equals 0
C = 0.               ; Sets the program counter to 0, which advances to 1 afterwards

Old solution used ASCII escape character 0x3 (ETX) in the string:

[]="\x03loL".$<[[0]--].[0]=[0]?[0]:2.C=0.

GitHub Repository

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

Turing Machine, 29 bytes

0 _ L r 1
1 _ o r 2
2 _ l r 1

Try it online!

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

makina, 14 bytes

v<<
>P^
 >tlo;

I AM BUTTER FEED ME BOT

\$\endgroup\$
2
  • \$\begingroup\$ Welcome to CGCC! I feel like I've seen you before though... \$\endgroup\$
    – Ginger
    May 20, 2023 at 20:20
  • \$\begingroup\$ @ButterFactory rewrite your responses to - oh wait wrong bot \$\endgroup\$
    – lyxal
    May 21, 2023 at 0:51
4
\$\begingroup\$

JavaScript (Node.js), 60 50 49 48 bytes

-10 bytes thanks to user

-1 byte by replacing while(1) with for(;;)

-1 byte thanks to ovs

for((p=x=>process.stdout.write(...x))`L`;;)p`ol`

Try it online!

\$\endgroup\$
0
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, 2020 at 3:38
  • \$\begingroup\$ That's really neat, don't you want to post it yourself? \$\endgroup\$ Sep 24, 2020 at 8:17
  • \$\begingroup\$ Unfortunately the question was closed as duplicate... \$\endgroup\$
    – Bubbler
    Sep 24, 2020 at 8:18
  • 1
    \$\begingroup\$ I've reopened the question and commented about why under the question. \$\endgroup\$ Sep 24, 2020 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\$

Wolfram Language (Mathematica), 31 bytes

#0[ol,$Output~WriteString~#]&@L

Try it online!

Stops when the program hits the $IterationLimit, which defaults to 4096.

34 bytes does the job without worrying about that:

Do[$Output~WriteString~L;L=ol,∞]

Try it online!

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

StupidStackLanguage, 26 bytes

avqvvmifavvqimiqdddltflflu

Try it online!

\$\endgroup\$
1
  • \$\begingroup\$ This sounds like an interesting language! \$\endgroup\$
    – user
    Sep 12, 2020 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, 2020 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\$ Sep 29, 2020 at 2:27
  • 1
    \$\begingroup\$ Welcome back, Conor :) \$\endgroup\$
    – Shaggy
    Sep 29, 2020 at 19:39
3
\$\begingroup\$

Raku, 14 chars, 16 bytes

Per standard rules, an infinite generator is acceptable.

{|<L ol>,~*…*}

Try it online!

Since this can be directly assigned or passed into other functions, the brackets aren't per se necessary but not sure if I can do that (if so, -2 chars/bytes). Enforcing the standard out bit is as simple as add a >>.print adds an extra 8 chars (22 chars, 24 bytes total).

(|<L ol>,~*…*)>>.print

Try it online!

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

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, 2021 at 14:43
3
\$\begingroup\$

Kotlin(script), 23 32 31 bytes

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

In Kotlin you need a top level declaration(main function) in order to compile code but Kotlin compiler also allows compiling Kotlin scripts using kotlinc -script lol.kts so yes you can compile one liners without top level direction using a file. this cannot be verified using TIO the only online compiler that I found for Kotlin scripting or Kotlin REPL is this site. In order to test this use command line in right side of the given site and and run the code in these steps:

First create a file:

echo "print(\"L\")while(0<1)print(\"ol\")" > lol.kts"

Then run it like this:

kotlinc -script lol.kts

Try it online!

\$\endgroup\$
2
  • 1
    \$\begingroup\$ Welcome to CGCC! Unfortunately, I'm not sure how to verify this on TIO; are you sure this works? The output is supposed to start with a capital L and print "olololol..."; this seems like it'd print "lollollollol..." (edit: testing with this shows the behavior I expected) \$\endgroup\$
    – hyper-neutrino
    May 16, 2021 at 2:34
  • 1
    \$\begingroup\$ @hyper-neutrino You're right this cannot be fully verified on TIO because it doesn't support Kotlin scripts. I missed the first capital L that, I'll fix it. \$\endgroup\$
    – Yamin
    May 16, 2021 at 2:46
3
\$\begingroup\$

C# 9, 55 47 bytes

for(var x="L";;x="ol")System.Console.Write(x);

Thanks, @ceilingcat!

Previously on Code Golf

var x="L";while(true){System.Console.Write(x);x="ol";}

Using top-level statements.

Microsoft's online compiler that doesn't like this infinite loop idea...

\$\endgroup\$
3
  • \$\begingroup\$ Welcome to the site! Would it be possible for you to add in a link to an online interpreter, such as TryItOnline, so others can run your code? \$\endgroup\$ Oct 27, 2020 at 23:37
  • \$\begingroup\$ Unfortunately, the only .NET 5.0 online interpreter is on Microsoft's site. This doesn't allow for injecting code. Plus, it locks up on this infinite loop. I'll add the link, but best of luck getting it to run. \$\endgroup\$ Oct 27, 2020 at 23:42
  • \$\begingroup\$ @ceilingcat ooo... I didn't think of that... \$\endgroup\$ Oct 28, 2020 at 15:18
3
\$\begingroup\$

Flipbit, 24 bytes

<<^>>>^>^>>.^<^<^<^<<,^]

Try it online!

or, using a bit less odd behavior:

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

Try it online!

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

Bash (pure bash), 43 34 31 bytes

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

Thanks manatwork

\$\endgroup\$
2
  • 2
    \$\begingroup\$ printf is shorter than echo -n. : is shorter than true. No need for the single quotes. \$\endgroup\$
    – manatwork
    Aug 5, 2021 at 20:34
  • 2
    \$\begingroup\$ If not done yet, take a look at Tips for golfing in Bash. Using those advices you may reduce this to printf L;for((;;)){ printf ol;}. \$\endgroup\$
    – manatwork
    Aug 5, 2021 at 20:43
3
\$\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
3
\$\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\$
3
\$\begingroup\$

Piet, 48 codels

Thanks @Bubbler for helping me golf my code from 66 to 48 codels by suggesting a 2 row layout instead of the 3 row layout that I initially used.

Answered as part of the current Piet LYAL event. Tell me if there are any golfs, I just started using Piet :P

Original code

Enlarged version

You can test the code on npiet online by downloading either image (npiet will auto-detect the size of each codel) and uploading the image file onto there.

You can also test the same code using its Ascii Piet encoding.

Ascii Piet, 48 bytes

tttliamtqimqqijsqrfeeeuLtt ii    qqqqi     fabsU

Try it online!

Explanation

PUSH 5            [5]
DUP               [5,5]
PUSH 3            [3,5,5]
MULTIPLY          [15,5]
MULTIPLY          [75]
DUP               [75,75]
PUSH 1            [1,75,75]
ADD               [76,75]
OUT(CHAR)         [75]       (prints L)
PUSH 6            [6,75]
DUP               [6,6,75]
MULTIPLY          [36,75]
ADD               [111]
DUP               [111,111]
OUT(CHAR)         [111]      (prints o)

(Start of two-row infinite loop)
DUP               [111,111]
PUSH 3            [3,111,111]
SUBTRACT          [108,111]
OUT(CHAR)         [111]      (prints l)
DUP               [111,111]
OUT(CHAR)         [111]      (prints o)
DIVIDE            [111]      (stack only has one number, instruction ignored)
GREATER           [111]      (stack only has one number, instruction ignored)

Even though the last two instructions don't seem to do anything, they actually act to convert the code back to the right color without affecting the functionality of the code. Because Piet instructions are entirely based on changes between the colors' hue and lightness, we need the color before the Dark Magenta color block in the infinite loop (e.g.: the color right under it) to be Dark Yellow, or else the Dark Magenta would correctly act as DUP the first time around (when entering the loop from the right), but be a different instruction in subsequent iterations of the loop, messing up the entire code.

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

Knight, 14 bytes

;O'L\'W1O'ol\'

Try It Online!

My first Knight answer :D

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

Trilangle, 13 bytes

"Loo,l",..o"v

Try it on the online interpreter!

The L serves both as a literal character and to redirect the IP.

Unfolds to this:

    "
   L o
  o , l
 " , . .
o " v . .

Instructions are, in order:

  • "L: Push 'L' to the stack
  • o: Print character
  • "o: Push 'o' to the stack
  • o: Print character
  • ,,: Pop twice (to keep memory bounded)
  • "l: Push 'l' to the stack
  • .: No-op
  • vL: Redirect the IP, closing the loop. | would work as well as v here.
\$\endgroup\$
3
\$\begingroup\$

Thue, 35 33 bytes

-2 thanks to SuperJedi224

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

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 (L) 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 (L), 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 (), and the second rule applies:

()::=(ol)

This means "replace () in the string with (ol)."

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

ol::=~ol

This means "delete ol from the string and output ol." Now the string is () again, rule 2 applies again, and we continue ad infinitum.

\$\endgroup\$
2
  • \$\begingroup\$ Consider removing the lowercase ol from the last line, save two bytes \$\endgroup\$ Mar 26, 2023 at 16:03
  • \$\begingroup\$ @SuperJedi224 Ah, of course! Thanks. \$\endgroup\$
    – DLosc
    Mar 27, 2023 at 4:34
3
\$\begingroup\$

MathGolf, 8 bytes

ûLoÉ_q!↑

Try it online!

I'm fairly new to this language, so this can probably be golfed.

Explanation

ûLo      # push the length two string "Lo"
   É   ↑ # while true, execute these three instructions:
    _    # duplicate
     q   # print without newline
      !  # lowercase
\$\endgroup\$

Your Answer

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

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