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
.
L
part and changeol
toA
, we get an SVL answer! \$\endgroup\$