In this challenge, you are required to shift characters in an inputted string n number of times and output the shifted string
Input will first contain a string. In the next line, an integer, which denotes
n will be present.
nis positive, shift the characters in the string to the right
nis negative, shift the characters in the string to the left
nis zero, don't shift the characters in the string.
After shifting (except when
n is zero), print the shifted string.
- The string will not be empty or
- The string will not be longer than 100 characters and will only contain ASCII characters in range
~(tilde) (character codes 0x20 to 0x7E, inclusive). See ASCII table for reference.
- The shift is cyclic.
- The number
nmay be positive, negative, or zero.
nwill always be greater than or equal to -1000 and lesser than or equal to 1000
- You may take input via
stdinor from command line arguments
- The shifted string must be outputted in the
stdout(or closest equivalent)
- You may write a full program or a function which takes input and outputs the string in
stdoutor closest equivalent
Hello world! 5 -->orld!Hello w
Testing... -3 -->ting...Tes
~~~ 1000 -->~~~
12345 0 -->12345
ABA 17 -->BAA
This is code-golf, so the shortest submission (in bytes) wins.