title: Compact Binary Representation

text:
# Question
Title: Compact Binary Representation
## Background

Often, when storing a number in binary with some maximum, we simply round the maximum to the next power of two then allocate the number of bits nececairy to store the whole range. Lets call the result of this method \\$S(x, m)\\$ where x is the number and m is the maximum.

While not bad, the naive has a few bits of redundancy since some bit patterns could only lead to a number beyond the max. You can exploit this to create a slightly shorter variable-length representation for numbers.

## The format

I will define such a format as follows:

* Let x be the number we want to represent and m be the max
* Let d the the difference between `m` and the next smaller power of 2. (in other words with the first 1 chopped of the binary representation)
* If m is 0, return the empty string
* If x is less than or equal to d:
    + Output "0" followed by f(x, m)
* Otherwise:
    + Output "1" followed by the log2(m)-bit binary representation of `x-d-1`.

Python translation:

```
def d(x): return x-(1<<x.bit_length()-1)

def f(x, m):
    if m==0:
        return ''
    if m==1: # edge cases needed to deal with the fact that binary coding in python produces at least one 0 even if you specify 0 digits
        return f'{x}'
    if x<=d(m):
        return '0'+f(x,d(m))
    else:
        return f'1{x-d(m)-1:0>{m.bit_length()-1}b}')

```

## Challenge

Output a pair of functions `f(x,m)` and `f'(y,m)` that convert to and from compressed binary representation for a given maximum.

You may assume `m>3` and `x<=m`.

The binary representation can be as a string, integer, list of ints, decimal coded binary, or anything else reasonable.

If you prefer you can take `m+1` as input instead of `m`. (exclusive maximum)

## Test Cases

Rows are X, columns are M

```
     5      6      7      8      9      10     11     12     13     14     15     16     17     18     19     20     21     22     23
     ------ ------ ------ ------ ------ ------ ------ ------ ------ ------ ------ ------ ------ ------ ------ ------ ------ ------ ------
    0 00     00     000    0      00     00     000    00     000    000    0000   0      00     00     000    00     000    000    0000
    1 01     010    001    1000   01     010    001    0100   001    0010   0001   10000  01     010    001    0100   001    0010   0001
    2 100    011    010    1001   1000   011    010    0101   0100   0011   0010   10001  10000  011    010    0101   0100   0011   0010
    3 101    100    011    1010   1001   1000   011    0110   0101   0100   0011   10010  10001  10000  011    0110   0101   0100   0011
    4 110    101    100    1011   1010   1001   1000   0111   0110   0101   0100   10011  10010  10001  10000  0111   0110   0101   0100
    5 111    110    101    1100   1011   1010   1001   1000   0111   0110   0101   10100  10011  10010  10001  10000  0111   0110   0101
    6        111    110    1101   1100   1011   1010   1001   1000   0111   0110   10101  10100  10011  10010  10001  10000  0111   0110
    7               111    1110   1101   1100   1011   1010   1001   1000   0111   10110  10101  10100  10011  10010  10001  10000  0111
    8                      1111   1110   1101   1100   1011   1010   1001   1000   10111  10110  10101  10100  10011  10010  10001  10000
    9                             1111   1110   1101   1100   1011   1010   1001   11000  10111  10110  10101  10100  10011  10010  10001
   10                                    1111   1110   1101   1100   1011   1010   11001  11000  10111  10110  10101  10100  10011  10010
   11                                           1111   1110   1101   1100   1011   11010  11001  11000  10111  10110  10101  10100  10011
   12                                                  1111   1110   1101   1100   11011  11010  11001  11000  10111  10110  10101  10100
   13                                                         1111   1110   1101   11100  11011  11010  11001  11000  10111  10110  10101
   14                                                                1111   1110   11101  11100  11011  11010  11001  11000  10111  10110
   15                                                                       1111   11110  11101  11100  11011  11010  11001  11000  10111
   16                                                                              11111  11110  11101  11100  11011  11010  11001  11000
   17                                                                                11111  11110  11101  11100  11011  11010  11001
   18                                                                                11111  11110  11101  11100  11011  11010
   19                                                                                11111  11110  11101  11100  11011
   20                                                                                11111  11110  11101  11100
   21                                                                                11111  11110  11101
   22                                                                                11111  11110
   23                                                                                11111

```

# Answer
# JavaScript (ES6), 65 + 67 = 132 bytes

## Encoder (65 bytes)

Expects `(x)(m)` and returns a binary string.

```
x=>g=m=>m?x>(m-=q=1<<Math.log2(m))?(q|x+~m).toString(2):0+g(m):""

```

Try it online!

### Commented

```
x =>                  // outer function taking x
g = m =>              // inner recursive function taking m
m ?                   // if m is not zero:
  x > (               //   if x is greater than
    m -=              //   the updated value of m defined as
    q =               //   m - q, where q is the highest
    1 << Math.log2(m) //   power of 2 less than or equal to m,
  ) ?                 //   then:
    (q |              //     use q for the leading 1
         x + ~m)      //     use x - m - 1 for the payload data
    .toString(2)      //     convert to binary
  :                   //   else:
    0 +               //     append a 0 and
    g(m)              //     do a recursive call with the updated m
:                     // else:
  ""                  //   stop

```

## Decoder (67 bytes)

Expects `(x,m)`, where `x` is a binary string. Returns an integer.

```
f=([c,...x],m)=>c?[f(x,m-=1<<Math.log2(m)),m-~`0b${x.join``}`][c]:0

```

Try it online!

### Commented

```
f = (                    // f is a recursive function taking:
  [c,                    //   c = next character in the binary string
      ...x],             //   x[] = array of remaining characters
  m                      //   m = maximum
) =>                     //
c ?                      // if c is defined:
  [                      //   return either:
    f(                   //     the result of this recursive call (*):
      x,                 //       pass x unchanged
      m -=               //       subtract from m the highest
      1 << Math.log2(m)  //       power of 2 less than or equal to m
    ),                   //     end of recursive call
    m - ~`0b${x.join``}` //     or m + x[] parsed as binary + 1
  ][c]                   //   according to c
:                        // else:
  0                      //   stop

```

*<sub>* Because this call is enclosed in an array, it is always executed regardless of whether the result is actually used or ignored. Since each recursion is guaranteed to stop as soon as the input string is fully consumed, this has no harmful side effects other than performance degradation.</sub>*
> 3 votes

# Answer
# Charcoal, 40 + 35 = 75 bytes

## Encoder, 40 bytes

```
ＮθＮηＷθ«≔↨²Ｅ↨θ²∧λκζ¿›ηζ«1≧⁻⊕ζη≧⁻⊕ζθ»«0≔ζθ

```

Try it online! Link is to verbose version of code. Explanation:

```
ＮθＮη

```

Input `m` and `x`.

```
Ｗθ«

```

Repeat until `m=0`.

```
≔↨²Ｅ↨θ²∧λκζ

```

Calculate `d` by setting the most significant bit of `m` to zero.

```
¿›ηζ«

```

If `x` is greater than `d`, then...

```
1≧⁻⊕ζη≧⁻⊕ζθ

```

... output a `1` and subtract `d+1` from `x` and `m`. This causes the rest of the bits to be encoded as binary.

```
»«0≔ζθ

```

Otherwise output a `0` and set `m` equal to `d`.

## Decoder, ~~36~~ 35 bytes

```
≔⍘Ｎ²θＩ∧Ση⊕⁺⍘⁺0Φθ›Σ…θκ⌕η1²⍘⁺0ΦηΣ…ηκ²

```

Try it online! Link is to verbose version of code. Explanation: Converts `m` to binary. If the value to be decoded contains any `1` bits, then a number of leading `1` bits is removed from the binary representation of `m`, and the first `1` bit is removed from the value to be decoded, and the two are then converted from binary, summed and incremented. Otherwise the output is simply zero.

Previous 36-byte decoder used a method similar to that of the encoder:

```
ＮθＦＳ«≔↨²Ｅ↨θ²∧λκζ¿Ｉι«Ｍ⊕ζ→≧⁻⊕ζθ»≔ζθ»Ｉⅈ

```

Try it online! Link is to verbose version of code. Explanation:

```
Ｎθ

```

Input `m`.

```
ＦＳ«

```

Loop over the bits to be decoded.

```
≔↨²Ｅ↨θ²∧λκζ

```

Calculate `d` by setting the most significant bit of `m` to zero.

```
¿Ｉι«

```

If the next bit is a `1`, then...

```
Ｍ⊕ζ→≧⁻⊕ζθ

```

... add `d+1` to `x` and subtract it from `m`. This causes the rest of the bits to be decoded as binary.

```
»≔ζθ

```

Otherwise set `m` equal to `d`.

```
»Ｉⅈ

```

Output the final value of `x`.
> 1 votes

---
Tags: code-golf, number, binary
---


# Question
Title: Repeated Consecutive Digital Product Sum Convergence
Given a positive integer `n` (***Example: `n=1234444999`***)

* Separate into consecutive digit runs:
    + `[1, 2, 3, 4444, 999]`
* Take the digital product of each run.
    + `[1, 2, 3, 4*4*4*4, 9*9*9] = [1, 2, 3, 256, 729]`
* Sum it...
    + 991
* Repeat until this converges to a single number:
    + 1234444999
    + 991
    + 82
    + 10
    + 1
* Return last number.

---

# Test Cases

```
BASE CASES:
0 = 0
...
9 = 9

OTHER CASES:
1234444999                     = 1
222222222222222                = 8
111222333444555666777888999000 = 9
11122233344455566677788899     = 8
1112223334445                  = 6
14536                          = 1
99                             = 9

```

# Requested Example:

```
334455553666333
9+16+625+3+216+27
896
8+9+6
23
2+3
**5**

```

# Winning?

It's , lowest byte-count is the winner.

# Answer
# 05AB1E, ~~7~~ ~~6~~ 5 bytes

Thanks to *Emigna* for saving a byte!

```
vSγPO

```

Uses the **05AB1E** encoding. Try it online!
> 8 votes

# Answer
# Japt, ~~17~~ ~~15~~ 13 bytes

```
e".+"_¬ò¦ x_×

```

Test it online! Takes input as a string.

Still not satisfied with this answer...

### Explanation

```
e".+"_  ¬ ò¦  x_  ×
e".+"Z{Zq ò!= xZ{Zr*1}}

e".+"                     Repeatedly replace all matches of /.+/ (the entire string)
     Z{               }   Z with this function:
       Zq                   Split Z into chars.
          ò!=               Partition at inequality; that is, split into runs of equal items.
              xZ{    }      Take the sum of: for each item in Z:
                 Zr*1         the item reduced by multiplication (i.e. the product).
                          This procedure is repeated until the same result is yielded twice.
                          Implicit: output result of last expression

```
> 6 votes

# Answer
# Jelly, 9 bytes

```
DŒgP€SµÐL

```

Try it online

Here's how it works:

```
D  - input as a list of digits
Œg - group runs of equal elements
P€ - the product of each element
S  - the sum of the list
µ  - syntax stuff to separate the left from the right
ÐL - repeat until we get a result twice, then return that result.

```
> 6 votes

# Answer
# Mathematica, ~~55~~ 42 bytes

```
#//.i_:>Tr[Times@@@Split@IntegerDigits@i]&

```

*-13 bytes from @JungHwan Min*. Thanx!

in case someone wants to use this as a random-digit-generator,
here is the tally of the first 100.000 numbers

> {{1, 17320}, {2, 4873}, {3, 10862}, {4, 11358}, {5, 10853}, {6, 9688}, {7, 11464}, {8, 10878}, {9, 12704}}
> *or if you gamble, don't put your money on 2!*
> 5 votes

# Answer
# Brachylog, 8 bytes

```
Ḋ|ẹḅ×ᵐ+↰

```

Try it online!

### Explanation

```
Ḋ          Input = Output = a digit
 |         Or
  ẹ        Split into a list of digits
   ḅ       Group consecutive equal elements together
    ×ᵐ     Map multiply
      +    Sum
       ↰   Recursive call

```
> 5 votes

# Answer
# Pyth, 11 bytes

```
us^M_MrjGT8

```

Try it online. Test suite.
> 4 votes

# Answer
# Python 3, 96 bytes

```
from itertools import*
f=lambda n:n*(n<10)or f(sum(int(k)**len([*g])for k,g in groupby(str(n))))

```

Try it online!
> 4 votes

# Answer
## JavaScript (ES6), ~~77~~ ~~73~~ ~~67~~ 65 bytes

*Saved 2 bytes thanks to @CraigAyre*

```
f=s=>s>9?f(''+eval(s.replace(/(.)\1*/g,s=>'+'+[...s].join`*`))):s

```

### How?

The input ***s*** is transformed into an arithmetic expression with:

```
s.replace(/(.)\1*/g, s => '+' + [...s].join`*`)

```

For instance, `1234444999` becomes `+1+2+3+4*4*4*4+9*9*9`.

We evaluate this expression and do a recursive call with the result until it's boiled down to a single decimal digit.

### Test cases

```
f=s=>s>9?f(''+eval(s.replace(/(.)\1*/g,s=>'+'+[...s].join`*`))):s

console.log(f("1234444999"                    )) // = 1
console.log(f("222222222222222"               )) // = 8
console.log(f("111222333444555666777888999000")) // = 9
console.log(f("11122233344455566677788899"    )) // = 8
console.log(f("1112223334445"                 )) // = 6
console.log(f("14536"                         )) // = 1
console.log(f("99"                            )) // = 9
```
> 3 votes

# Answer
## Husk, 8 bytes

```
ωöṁΠgmis

```

Takes and returns an integer. Try it online!

## Explanation

Having a built-in for base 10 digits would be nice...

```
ωöṁΠgmis
ω         Iterate until a fixed point is found
 ö        the composition of the following four functions:
       s   convert to string,
     mi    convert each digit to integer,
    g      group equal adjacent integers,
  ṁΠ       take product of each group and sum the results.

```
> 3 votes

# Answer
# PHP, 113 bytes

```
for(;9<$a=&$argn;$a=$s){$s=0;preg_match_all('#(.)\1*#',$argn,$t);foreach($t[0]as$v)$s+=$v[0]**strlen($v);}echo$a;

```

Try it online!
> 2 votes

# Answer
# MATL, 11 bytes

```
`!UY'^sVtnq

```

Try it at MATL Online

**Explanation**

```
        % Implicitly grab input as a string
`       % Do...while loop
  !U    % Convert the string to an array of numbers (the digits)
  Y'    % Perform run-length encoding
  ^     % Raise the digits to the power corresponding to the number of times they
        % occurred consecutively
  s     % Sum the result
  V     % Convert to a string
  tn    % Duplicate and determine the number of characters in the string
  q     % Subtract one, causes the loop to continue until it's a single digit
        % Implicit end of do...while loop and display

```
> 2 votes

# Answer
# CJam, 22 bytes

```
r_,{1/e`Wf%::i::#:+s}*

```

Try it online!
> 2 votes

# Answer
# Braingolf, 25 bytes

```
!L1-Mv[RG(d&*)&+!L1-Mv>]R

```

Will add a TIO link once I get Dennis to pull the latest version, as using greedy operators inside `(...)` loops is currently broken on TIO

## Explanation

```
!L1-Mv[RG(d&*)&+!L1-Mv>]R  Implicit input from commandline args
!L1-M                      Push length of input minus 1 to stack2
     v                     Switch to stack2
      [.........!L1-Mv>]   While length of input > 1..
       RG                  Split into digit runs
         (d&*)             Product of digits of each item in stack
              &+           Sum stack
                        R  Return to stack1
                           Implicit output from stack

```
> 2 votes

# Answer
# Haskell, 103 70 69 bytes

```
import Data.List
until(<10)$sum.map product.group.map(read.pure).show

```

Try it online!
> 2 votes

# Answer
# K (ngn/k), ~~17~~ 23 bytes

+6 bytes from handling cases where the same digit is present in multiple chunks

```
{+/*/'(&~=':x)_x:10\x}/

```

Try it online!

* `{...}/` run a converge reduction over the input
* `x:10\x` convert input to a list of digits, updating `x`
* `(&~=':x)` identify indices where the value differs from the previous element
* `(...)_x` split the list of digits on those indices
* `*/'` take the product of each chunk
* `+/` add those products together

Fails on inputs too large for 64-bit integers.
> 2 votes

# Answer
# , ~~114~~ 104 bytes

```
n=scan(,'');while(nchar(n)>1){n=el(strsplit(n,''));b=table(n);n=as.character(sum(strtoi(names(b))^b))};n

```

reads from stdin; returns the answer as a string.

Try it online!
> 1 votes

# Answer
# R, ~~97~~ 96 bytes

```
a=scan(,"");while(nchar(a)>1){a=paste(sum(strtoi((b<-rle(el(strsplit(a,""))))$v)^strtoi(b$l)))}a

```

Slightly different approach than the other answer using **R**.

This answer makes use of the `rle` function, which `compute[s] the lengths and values of runs of equal values in a vector`.

*-1* bytes thanks to @Giuseppe !
> 1 votes

# Answer
# Perl 5, 50 bytes

49 bytes of code + `-p` flag.

```
s/(.)\1*/"+".$&=~s%.%$&*%gr.1/ge while($_=eval)>9

```

Try it online!
> 1 votes

# Answer
# Japt, 19 bytes

```
=ò¦ m¬®×Ãx)<A?U:ßUs

```

Try it online!

## Explanation:

```
=ò¦ m¬®×Ãx)<A?U:ßUs
=                    // Implicit U (input) =
 ò¦                  //   Split the input into an array of consecutive digit runs
    m¬               //   Split each inner array: ["1","22","333"] -> [["1"],["2","2"],["3","3","3"]]
      ®              //   Map; At each item:
       ×             //     Get the product of each run
        Ã            //   }
         x           //   Sum
           <A        // <10
             ?       // If true:
              U      //   return U
               :     // Else:
                ß    //   Run the program again; Pass:
                 Us  //     U, cast to a string

```
> 1 votes

# Answer
# J-uby, 45 bytes

```
:!~&(:digits|:slice_when+:!=|:*&(:/&:*)|:sum)

```

Attempt This Online!

## Explanation

```
:!~ & (:digits | :slice_when + :!= | :* & (:/ & :*) | :sum)

:!~ & (                                                   )  # Apply the following function until F(x) == x
       :digits |                                             #   Get digits
                 :slice_when + :!= |                         #   Group like elements (slice between unequal)
                                     :* & (:/ & :*) |        #   Map with reduce with product
                                                      :sum   #   Sum

```
> 1 votes

# Answer
# Vyxal 3 `g`, 6 bytes

```
ᵡλġᵛΠ∑

```

Try it Online!
> 1 votes

# Answer
# Japt `-h`, 9 bytes

I/O as digit arrays

```
£=òÎx_×Ãì

```

Try it

```
£=òÎx_×Ãì     :Implicit input of digit array
£             :Map
 =            :  Reassign to U
  ò           :  Partition between elements where
   Î          :    The sign of their difference in truthy (not zero)
    x         :  Reduce by addition
     _        :  After passing each through this function
      ×       :    Reduce by multiplication
       Ã      :  End function
        ì     :  Split to digit array
              :  Implicit output of last element

```
> 0 votes

# Answer
# Groovy, ~~69~~ 68 bytes

```
f={r->r>9?f((r=~/(.)\1*/)*.tap{}.sum{n->n[1]as int**n[0].size()}):r}

```

Requires Groovy 3.x.

## Explanation

If the input is single digit, returns it, else recursively calls the function on the next pass of the algorithm.

```
f={r->r>9?f(...):r}     : Recursively call algorithm if input > 9, else return input
r=~/(.)\1*/)            : Regex capture of each run, e.g. [["444", "4"], ["2", "2"]]
*.tap{}                 : Convert Matcher to List<List<Integer>> so we can call sum()
.sum{...}               : Apply the closure to each List element and sum them
n[1]as int**n[0].size() : <digit>^<run length> from e.g. ["444", "4"]

```
> 0 votes

# Answer
# Uiua SBCS, ~~20~~ 17 bytes

```
⍥(/+⊜/×+1.-@0°⋕)∞

```

Try it!
> 0 votes

---
Tags: code-golf, sequence
---


title: Lolololololololololololol

text:
# Question
Title: Lolololololololololololol
**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!

# Answer
> 27 votes
# 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.

# Answer
> 23 votes
# 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.

# Answer
> 22 votes
# 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...`.

# Answer
> 18 votes
# 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:

*Forever and ever...*

# Answer
> 11 votes
# brainfuck, ~~41~~ 40 bytes

-1 byte thanks @ovs

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

```

Try it online!

# Answer
> 11 votes
# 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`.

# Answer
> 10 votes
# 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`.

# Answer
> 9 votes
# Haskell, 13 bytes

```
'L':cycle"ol"

```

Try it online!

# Answer
> 9 votes
# Java (JDK), ~~51~~ ~~48~~ 47 bytes

```
a->{for(var s="L";;s="ol")System.out.print(s);}

```

Try it online!

thanks to user and Jo King helping me save 4 and 1 byte(s) respectively!

# Answer
> 8 votes
# 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)

```

# Answer
> 8 votes
# 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

# Answer
> 7 votes
# 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!**

# Answer
> 7 votes
# PHP, 24 bytes

```
L<?php for(;;)echo'ol';

```

# Answer
> 7 votes
# 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.

# Answer
> 7 votes
# C (gcc), 27 bytes

```
f(i){f(!printf("Lol"+!i));}

```

Try it online!

# Answer
> 7 votes
# convey, 10 bytes

```
['L'}'lo'}

```

Try it online!

Visualization (separated)

# Answer
> 6 votes
# 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"

```

# Answer
> 6 votes
# Hexagony, ~~11~~ 6 bytes

-5 thanks to @Bubbler

```
L;o;l;

```

Try it online!

```
  L ;   Executed once: Set memory to 'L' (76) and print
 o ; l  Executed repeatedly: Set memory to 'o' (111), print, set memory to 'l' (108)
  ; .   Executed repeatedly: Print

```

After the first row is executed once, the second and third rows are repeatedly executed, infinitely printing `ol`.

# Answer
> 6 votes
# Cascade, ~~22~~ 14 bytes

```
@o|
.l@
L"^
/"

```

Try it online!

-8 thanks to Jo King.

# Answer
> 5 votes
### **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:

# Answer
> 5 votes
# braingasm, 12 bytes

```
76.28524+[.]

```

Prints the byte streams `76` once, then `28524` forever

# Answer
> 5 votes
# Vim `+startinsert`, ~~14~~ 11 bytes

```
ol<C-v><C-r>"<C-o>ddL<C-r>"

```

Try it online!

In TIO, when the recursive register expansion (RRE) times out, nothing is outputted since it didn't finish expanding. In Vim, you may not see anything right away since the console might freeze during the RRE, but if you `Ctrl`+`C`, you can stop the expansion and see that it does work.

Explanation:

```
                              # '+startinsert' flag - start vim in insert mode; TIO equivalent is 'i' in the header
ol<C-v><C-r>"                 # Insert 'ol<C-r>"'
              <C-o>           # Run normal mode command, then return to insert mode:
                   dd         #   Delete 'ol<C-r>"' into unnamed register
                     L        # Insert 'L'
                      <C-r>"  # Insert unnamed register, which recursively expands to 'ol' + unnamed register

```

# Answer
> 5 votes
# 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.

# Answer
> 5 votes
# 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.

# Answer
> 5 votes
# Forte (Forter), 25 bytes

```
5PRINT"ol";:LET5=1
1PUT76

```

Try it online!

### Explanation

An undefined behavior exploit courtesy of Jo King:

```
1 PUT 76

```

Print an `L` character.

```
5 PRINT "ol"; : LET 5 = 1

```

Print `ol` without a final newline, and set 5 to 1.

Apparently, this overwrites the former line 1 with the former line 5, and thus (lacking an `END` statement) the `PRINT "ol";` line is executed repeatedly forever. But I don't really understand how this works--especially since it only works if you write line 5 before line 1, not vice versa...

---

Here's a **44-byte** version that doesn't use any undefined behavior:

```
1PUT76
5PRINT"ol";:LET6=6+0
6LET0=2:LET5=5+2

```

Try it online!

### Explanation

```
1 PUT 76

```

Print an `L` character.

```
5 PRINT "ol"; : LET 6 = 6 + 0

```

Print `ol` without a final newline, and set 6 to 6.

```
6 LET 0 = 2 : LET 5 = 5 + 2

```

Set 0 to 2, and set 5 to 7.

```
~~5~~ 7 PRINT "ol"; : LET 6 = 6 + ~~0~~ 2
```

Print `ol` again, and set 6 to 8.

```
~~6~~ 8 LET ~~0~~ 2 = 2 : LET ~~5~~ 7 = ~~5~~ 7 + 2
```

Set 2 to 2, and set 7 to 9.

```
~~5~~ ~~7~~ 9 PRINT "ol"; : LET ~~6~~ 8 = ~~6~~ 8 + ~~0~~ 2
```

Print `ol` again, and set 8 to 10.

And so on forever.

# Answer
> 5 votes
Neither beats Johan du Toit's answer, but I enjoy that they are full programs, plus I like the way the longjmp answer works.

# C (gcc), 39 bytes

As straight forward as it gets, uses `for` initializer to print `L`, then it's `ol`s from there on out.

```
main(){for(printf("L");printf("ol"););}

```

Try it online!

# C (gcc), 50 bytes

Definitely more fun, use an int array as jmp\_buf, then add the return of setjmp to the string pointer so that the first iteration adds 0, then pass 1 to longjmp so the rest add 1 and skip the `L`.

Thanks to jdt for -4 bytes!

```
j[9];main(){printf("Lol"+setjmp(j));longjmp(j,1);}

```

Try it online!

# Answer
> 5 votes
# Pyramid Scheme, 200 bytes

```
  ^     ^
 / \   / \
/out\ /do \
-----^-----^
    / \   ^-
   /chr\ / \
  ^-----/out\
 / \   ^-----^
/76 \ / \   ^-
-----/chr\ / \
    ^-----/chr\
   / \   ^-----
  /111\ / \
  -----/108\
       -----

```

Try it online!

This *seems* to be the shortest way that I can find. This language isn't easy to golf in.

# Answer
> 4 votes
# 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"

```

# Answer
> 4 votes
# 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 `ol`s 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.

# Answer
> 4 votes
# 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" (`Ƚ`)

# Answer
> 4 votes
# 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.

# Answer
> 4 votes
# dc, 14 bytes

```
76P[[ol]Pdx]dx

```

Try it online!

# Answer
> 4 votes
# Vyxal `5`, 9 bytes

```
\L₴{`ol`₴

```

Try it Online!

# Answer
> 4 votes
# \>\<\> 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

```

# Answer
> 4 votes
# 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.

# Answer
> 4 votes
# 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!

# Answer
> 4 votes
# 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

# Answer
> 4 votes
# BitCycle, 30 bytes

```
v001000<   ~010!

~1011000110^

```

Try it online!

Outputs as a stream of bits.

# Answer
> 4 votes
# 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

# Answer
> 4 votes
# Turing Machine, 29 bytes

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

```

Try it online!

# Answer
> 4 votes
# makina, 14 bytes

```
v<<
>P^
 >tlo;

```

I AM BUTTER FEED ME BOT

# Answer
> 3 votes
# 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!

# Answer
> 3 votes
# StupidStackLanguage, 26 bytes

```
avqvvmifavvqimiqdddltflflu

```

Try it online!

# Answer
> 3 votes
# 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

```

# Answer
> 3 votes
## 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.

# Answer
> 3 votes
# 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!

# Answer
> 3 votes
# !@#$%^&\*()\_+, 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

```

# Answer
> 3 votes
# 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")}}

```

# Answer
> 3 votes
# 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!

# Answer
> 3 votes
# 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...

# Answer
> 3 votes
# 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!

# Answer
> 3 votes
# Flipbit, 24 bytes

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

```

Try it online!

or, using a bit less odd behavior:

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

```

Try it online!

# Answer
> 3 votes
# 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!

# Answer
> 3 votes
# Bash (pure bash), 43 34 31 bytes

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

```

Thanks manatwork

# Answer
> 3 votes
## 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.*

# Answer
> 3 votes
# 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.

# Answer
> 3 votes
# 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.

# Answer
> 3 votes
# Knight, 14 bytes

```
;O'L\'W1O'ol\'

```

Try It Online!

My first Knight answer :D

# Answer
> 3 votes
# 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.

# Answer
> 3 votes
# 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

```

# Answer
> 2 votes
# 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"

```

# Answer
> 2 votes
# 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!

# Answer
> 2 votes
# 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

```

# Answer
> 2 votes
# 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'}}

```

# Answer
> 2 votes
# , ~~26~~ 25 bytes

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

```

Try it online!

Well, this one is pretty straightforward.

*−1 byte thanks to Steffan*

# Answer
> 2 votes
# MAWP, 10 bytes

```
76;["ol":]

```

Try it!

# Answer
> 2 votes
# Scala, ~~35~~ ~~34~~ 32 bytes

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

```

Try it online!

* -1 thanks to ovs!

# Answer
> 2 votes
## 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".

# Answer
> 2 votes
# 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']

```

# Answer
> 2 votes
# 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.

```

# Answer
> 2 votes
# 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:

# Answer
> 2 votes
# \>\<\>, 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

```

# Answer
> 2 votes
# Canvas, 6 bytes

```
LＷol＋］

```

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.

# Answer
> 2 votes
# 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.

# Answer
> 2 votes
# 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

```

# Answer
> 2 votes
# 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.

# Answer
> 2 votes
# Factor, 29 bytes

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

```

Try it online!

# Answer
> 2 votes
# Vyxal, 8 bytes

```
\L₴{‛ol₴

```

Try it Online!

Will add an explanation soon.

# Answer
> 2 votes
# Pari/GP, 22 bytes

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

```

Try it online!

---

# Pari/GP, 22 bytes

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

```

Try it online!

# Answer
> 2 votes
# 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

```

# Answer
> 2 votes
# 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"

```

# Answer
> 2 votes
# \>\<\>, 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 `>`)

# Answer
> 2 votes
# Lean Mean Bean Machine, 19 bytes

```
OOO
"""
Lol
U!!
 ~~

```

Try it online!

Lol

# Answer
> 2 votes
# 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`

```

# Answer
> 2 votes
# 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

```

# Answer
> 2 votes
# 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.

# Answer
> 2 votes
# 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.

# Answer
> 1 votes
# Splinter, 11 bytes

```
A{\o\lA}\LA

```

Try it online!

Interpreter breaking version. Would run forever otherwise.

# Answer
> 1 votes
# 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.)

# Answer
> 1 votes
# Lua, 31 bytes

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

```

Try it online!

# Answer
> 1 votes
## GForth 30 bytes

```
: A ." L" 0 1 do ." ol" loop ;

```

# Answer
> 1 votes
## 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.

# Answer
> 1 votes
# Haskell, 25 bytes

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

```

To return an infinite string, only 13 bytes required:

```
'L':cycle"ol"

```

# Answer
> 1 votes
# 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)

```

# Answer
> 1 votes
# BrainCrash, ~~43~~ 22 bytes.

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

```

I'll golf off later.

Try it online!

# Answer
> 1 votes
# 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⌋⟩∞`.

# Answer
> 1 votes
# JavaScript (Node.js), 49 bytes

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

```

Try it online!

# Answer
> 1 votes
# APL (Dyalog Unicode), 14 bytes

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

```

Try it online!

# Answer
> 1 votes
# Pyth, 8 bytes

```
p\LWp"ol

```

Try it online!

# Answer
> 1 votes
# Etch, 23 bytes

```
do
:outnnl"lo";
forever

```

# Answer
> 1 votes
# 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!

# Answer
> 1 votes
# 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!

# Answer
> 1 votes
## PHP (25 chars)

```
echo'L';for(;;print'ol');

```

# Answer
> 1 votes
# 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.

# Answer
> 1 votes
# Rust, 41 bytes

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

```

Try it online!

# Answer
> 1 votes
# 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

```

# Answer
> 1 votes
# 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

```

# Answer
> 1 votes
# 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:

Magnified 70x with RGB colors labeled:

# Answer
> 1 votes
# 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.

# Answer
> 1 votes
# Nibbles, 5 bytes (10 nibbles)

```
"L"^~"ol"

```

Attempt This Online!

# Answer
> 1 votes
# Python, 45 Bytes

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

```

Try it online!
Seems ungolfable.

# Answer
> 1 votes
# 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;

```

# Answer
> 1 votes
# \>\<\> (Fish), 13 bytes

```
'L'o'lo'oo30.

```

Try it

# Answer
> 1 votes
# 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.

# Answer
> 1 votes
# Basic, 20 bytes

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

```

Try it online!

# Answer
> 1 votes
# JavaScript (Node.js), 41 bytes

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

```

Try it online!

-2 from Dom Hastings

# Answer
> 1 votes
# Vyxal 3, 7 bytes

```
'L{§ᶴol

```

Try it Online!

Lolololololol

# Answer
> 1 votes
# Uiua 0.3.1, 16 bytes

```
⍢(&pf"ol")1&pf@L

```

See it in action

# Answer
> 1 votes
# Hussy.Net, 17 bytes

```
A("L");R(A,"ol");

```
* `A` is an append function that simply writes the specified input to the output stream.
* `R` is a repeater function that repeats the specified action with the specified input until an optionally specified escape condition is met.

# Answer
> 0 votes
# 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.

# Answer
> 0 votes
# Desmos Graphing Calculator, 28 bytes

```
t->t+1
t=0
(0,0)
([0...t],0)

```

The first line is a ticker, which automatically increases the number.

Try it on Desmos!
Decreasing the byte count can be done by using a custom interactive slider (but I didn't include it because it feels like cheating): Try here!

# Answer
> 0 votes
# /// 9 bytes

```
L/./ol./.

```

Of course, you'll have to wait for the *end of time* to see the output, but wasn't this part of the challenge? (-;

# Answer
> 0 votes
# \>\<x\>, 58 bytes

Makes use of the fact that the accumulator is bound to the range `[0, 255]`.

```
iiissdddddoddsiiiiiiii>iiiov
                      ^oddd<

```

## Explanation

**Initializer**

```
iii                      Increase the accumulator to 3
   s                     Square it to get 9
    s                    Square it again to get 81
     ddddd               Reduce the accumulator by 5 to get 76
          o              Print the ASCII value of the accumulator, "L"
           dd            Decrement the accumulator by 2
             s           Square it to get 74^2 & 255, which is 100
              iiiiiiii   Increase the accumulator by 8

```

**The loop**

```
>        Force the IP to the right
 iii     Increment by 3
    o    Print the ASCII value of the accumulator, "o"
     v   Force the IP downward
     <   Force the IP to the left
  ddd    Decrement by 3
 o       Print the ASCII value of the accumulator, "l"
^        Force the IP upward

```

# Answer
> 0 votes
# Perl 5, 25 bytes

```
print"L";print'ol'while 1

```

Try it online!

# Answer
> 0 votes
# YASEPL, 11 bytes

```
#"L"#"ol"?2

```

# Answer
> 0 votes
# Rust, 41 bytes

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

```

Try it online!

---
Tags: code-golf, string, sequence
---