Determine the cyclical shift your program is in
brainfuck, 3 bytes
.++
Try it online!
how it works: it's really simple, actually. The internal memory is initialized at 0 so we output (with .
) the original cell and we get 0. By shifting the program, we are shifting memory increments (done with +
) to before the output, so each byte shifted corresponds to one more increment, and hence we increase the counter.
Jelly, 3 bytes
‘n¬
The implicit input of a Jelly program is 0
:
Try ‘n¬
online! 0
incremented \$\neq\$ not(0
) \$\implies0+1 \neq 1 \implies 1\neq 1 \implies 0\$
Try ¬‘n
online! not(0
) incremented \$\neq\$ 0
\$\implies1+1\neq 0 \implies 2\neq 0 \implies 1\$
Try n¬‘
online! (0
\$\neq\$ not(0
)) incremented \$\implies(0\neq 1)+1 \implies 1+1 \implies 2\$
Keg -hd
, 3 bytes
210
Try it online!
How?
Keg only outputs the top item of the stack. These individual digits push themselves onto the stack. So for every cyclic shift, it outputs the character code of the top of the stack.
Program -> Stack -> Output last item
210 -> [2, 1, 0] -> [0]
021 -> [0, 2, 1] -> [1]
102 -> [1, 0, 2] -> [2]