Back
Close

LR shifting

Statement

 Goal

You must shift a sequence of integers a number of positions to the left or to the right and print the shifted sequence.
The sequence is shifted pos positions to the left or to the right.
Input
Line 1: An integer N for the number of elements.
Line 2: N space separated integers.
Line 3: A string direction and an integer pos separated by a space.
Output
A single line: N space separated integers.
Constraints
3 ≤ N ≤ 100;
direction is "Left" or "Right".
0 < pos ≤ 25
Example
Input
5
6 9 2 1 0
Left 1
Output
9 2 1 0 6

Game modes
Fastest, Shortest

Test cases
Test 1 Test
Input
5 6 9 2 1 0 Left 1
Output
9 2 1 0 6

Validator 1 Validator
Input
5 7 9 2 1 0 Left 1
Output
9 2 1 0 7

Test 2 Test
Input
6 4 7 10 98 19 70 Right 2
Output
19 70 4 7 10 98

Validator 2 Validator
Input
6 4 7 15 98 19 70 Right 2
Output
19 70 4 7 15 98

Test 3 Test
Input
15 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Left 4
Output
5 6 7 8 9 10 11 12 13 14 15 1 2 3 4

Validator 3 Validator
Input
15 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Left 5
Output
6 7 8 9 10 11 12 13 14 15 1 2 3 4 5

Test 4 Test
Input
12 6 8 1 9 4 5 0 5 9 2 3 7 Right 7
Output
5 0 5 9 2 3 7 6 8 1 9 4

Validator 4 Validator
Input
12 6 8 2 9 4 5 0 5 9 2 3 7 Right 7
Output
5 0 5 9 2 3 7 6 8 2 9 4

Test 5 Test
Input
100 34 87 86 96 29 81 92 10 91 12 78 37 77 7 22 70 98 26 20 48 13 17 16 68 35 43 18 60 88 56 24 65 25 33 32 11 27 2 41 9 3 76 31 67 57 36 55 85 19 14 30 79 38 58 63 61 75 6 71 21 49 82 84 80 23 69 28 39 100 46 4 52 5 73 42 72 93 8 62 53 83 66 99 90 15 94 51 95 40 89 47 54 64 59 1 74 45 50 97 44 Right 23
Output
8 62 53 83 66 99 90 15 94 51 95 40 89 47 54 64 59 1 74 45 50 97 44 34 87 86 96 29 81 92 10 91 12 78 37 77 7 22 70 98 26 20 48 13 17 16 68 35 43 18 60 88 56 24 65 25 33 32 11 27 2 41 9 3 76 31 67 57 36 55 85 19 14 30 79 38 58 63 61 75 6 71 21 49 82 84 80 23 69 28 39 100 46 4 52 5 73 42 72 93

Validator 5 Validator
Input
100 34 87 86 96 29 81 92 10 91 12 78 37 77 7 22 70 98 26 20 48 13 17 16 68 35 43 18 60 88 56 24 65 25 33 32 11 27 2 41 9 3 76 31 67 57 36 55 85 19 14 30 79 38 58 63 61 75 6 71 21 49 82 84 80 23 69 28 39 100 46 4 52 5 73 42 72 93 9 63 53 83 66 99 90 15 94 51 95 40 89 47 54 64 59 1 74 45 50 97 44 Right 23
Output
9 63 53 83 66 99 90 15 94 51 95 40 89 47 54 64 59 1 74 45 50 97 44 34 87 86 96 29 81 92 10 91 12 78 37 77 7 22 70 98 26 20 48 13 17 16 68 35 43 18 60 88 56 24 65 25 33 32 11 27 2 41 9 3 76 31 67 57 36 55 85 19 14 30 79 38 58 63 61 75 6 71 21 49 82 84 80 23 69 28 39 100 46 4 52 5 73 42 72 93

Test 6 Test
Input
12 10 17 120 79 54 16 45 87 90 55 11 13 Right 18
Output
45 87 90 55 11 13 10 17 120 79 54 16

Validator 6 Validator
Input
12 10 17 120 79 54 16 45 87 90 55 11 14 Right 18
Output
45 87 90 55 11 14 10 17 120 79 54 16

Test 7 Test
Input
10 5 9 4 2 8 1 3 6 9 7 Left 14
Output
8 1 3 6 9 7 5 9 4 2

Validator 7 Validator
Input
10 5 9 4 2 8 1 5 6 9 7 Left 14
Output
8 1 5 6 9 7 5 9 4 2

Solution language

Solution

Stub generator input