Skip to main content
2 of 2
added 178 characters in body
Bubbler
  • 78.4k
  • 5
  • 149
  • 469

Stack Cats with -nl, 18 bytes

*(>]>{<:_-!:]}[*)>

Try it online!

Flags are not counted as bytes, but as a separate language as per this Meta consensus.

Flags:

  • -n to do integer I/O
  • -l to implicitly mirror to the left; the actual code is <(*]{[:!-_:>}<[<)*(>]>{<:_-!:]}[*)>.

Adapted from this answer for printing out 1 to 10. I had to fall back to the <(...)*(...)> structure to handle the input correctly. (I once tried _(...)_(...)_ instead, but I realized it is incorrect for n=1.)

How it works:

     [-1 n*]
<    [*] [-1 n]
(..) Skip
*    [1*] [-1 n]
(
>]>  [1] [-1] [n] [*]
{    Remember 0
<:   [1] [-1] [n 0*] [...]
_-!  [1] [-1] [n n-1*] [...]
:]   [1] [-1] [n-1] [... n*]
}    Exit if top is 0
[    Remove 0 at the top
*    Make the top positive
)    Top = 1; exit
>    Return to the stack of numbers
Bubbler
  • 78.4k
  • 5
  • 149
  • 469