Skip to main content
Made safe
Source Link
DLosc
  • 39.2k
  • 5
  • 83
  • 141

???Ouroboros, 27 bytes, safe

$0$1@l();
($1+JOYjoy$100=_)

Outputs as bytes.


Try it here!

Ouroboros is usually pretty distinctive with constructs like 1( at the ends of lines, so I tried to get creative with the parentheses to disguise it. Also with $ before numbers to make it look vaguely Perl-inspired.

Snake 1

$  Switch to shared stack
0  Push 0
$  Switch back to own stack
1  Push 1
@  Rotate top 3; since there's only one item on the stack, uses two implicit zeros
l  Push length of stack (3)
(  Eat that many characters from the end of the snake

This swallows the IP, and the snake halts.

Snake 2

(   Swallow characters; with an empty stack, swallows 0 characters: no-op
$   Switch to shared stack (on the first iteration, this just had a 0 pushed to it by
    snake 1; on future iterations, it will be the previous number printed)
1   Push 1
+   Add
JO  No-ops
Y   Copy top of shared stack to own stack
j   No-op
o   Output top of current stack (which is the shared stack) as ASCII character
y   Copy top of own stack to shared stack
    We now have a copy of the current number on each stack
$   Switch to own stack
100 Push 100
=   Push 1 if 100 equals current number, 0 otherwise
_   Negate
)   Regurgitate that many characters: if 0, does nothing; if -1, swallows a character

Thus, if the current number is 100, the IP is swallowed and the snake halts; otherwise, control loops back to the beginning of the snake, where we switch back to the shared stack, increment the number there, and so forth.

???, 27 bytes

$0$1@l();
($1+JOYjoy$100=_)

Outputs as bytes.

Ouroboros, 27 bytes, safe

$0$1@l();
($1+JOYjoy$100=_)

Outputs as bytes.


Try it here!

Ouroboros is usually pretty distinctive with constructs like 1( at the ends of lines, so I tried to get creative with the parentheses to disguise it. Also with $ before numbers to make it look vaguely Perl-inspired.

Snake 1

$  Switch to shared stack
0  Push 0
$  Switch back to own stack
1  Push 1
@  Rotate top 3; since there's only one item on the stack, uses two implicit zeros
l  Push length of stack (3)
(  Eat that many characters from the end of the snake

This swallows the IP, and the snake halts.

Snake 2

(   Swallow characters; with an empty stack, swallows 0 characters: no-op
$   Switch to shared stack (on the first iteration, this just had a 0 pushed to it by
    snake 1; on future iterations, it will be the previous number printed)
1   Push 1
+   Add
JO  No-ops
Y   Copy top of shared stack to own stack
j   No-op
o   Output top of current stack (which is the shared stack) as ASCII character
y   Copy top of own stack to shared stack
    We now have a copy of the current number on each stack
$   Switch to own stack
100 Push 100
=   Push 1 if 100 equals current number, 0 otherwise
_   Negate
)   Regurgitate that many characters: if 0, does nothing; if -1, swallows a character

Thus, if the current number is 100, the IP is swallowed and the snake halts; otherwise, control loops back to the beginning of the snake, where we switch back to the shared stack, increment the number there, and so forth.

Source Link
DLosc
  • 39.2k
  • 5
  • 83
  • 141

???, 27 bytes

$0$1@l();
($1+JOYjoy$100=_)

Outputs as bytes.