Skip to main content
2 of 3
added 762 characters in body
Adám
  • 31.8k
  • 4
  • 131
  • 293

APL (Dyalog Unicode), 15 bytes

Full program, prompting for input via stdin. The structure is an anonymous infix function which due to the shifting gets either 10 or 100 or 1 as its right argument. The (optional) left argument of 0 or nothing or 00 is ignored. Then we divide the right argument by 10 giving us 1 or 10 or 0.1 and find the 10-logarithm of that, giving us 0 or 1 or -1. Finally we prompt for input and shift by that amount.

--- 0{⍞⌽⍨10⍟⍵÷10}10

Try it online!

{} anonymous infix function where is the right argument; 10

⍵÷10 divide the right argument by ten; 1

10⍟ log10 of that; 0

⌽⍨ cyclically rotate the following by that number of steps:

 stdin


{⍞⌽⍨10⍟⍵÷10}100 

Try it online!

{} anonymous infix function where is the right argument; 100

⍵÷10 divide the right argument by ten; 10

10⍟ log10 of that; 1

⌽⍨ cyclically rotate the following by that number of steps:

 stdin

--- 00{⍞⌽⍨10⍟⍵÷10}1

Try it online!

{} anonymous infix function where is the right argument; 0

⍵÷10 divide the right argument by ten; 0.1

10⍟ log10 of that; -1

⌽⍨ cyclically rotate the following by that number of steps:

 stdin

---

Adám
  • 31.8k
  • 4
  • 131
  • 293