Retired

In Single File (retired)

Description:

Do you remember stand in single file in gym class at school?

The first element should be placed last. And so on until again the first was the first again.


Now think of an array whit elements.

The first element of the array becomes the last one and the others are moved one index to the left.

This operation is repeated until before the array returns to its original position.

For this kata you will receive an array.

Returns a two-dimensional array whose elements are arrays, each with one rotation of the original array, starting with the original array until the one in which the first element occupies index 1.

It might be easier to look at the examples.

EXAMPLES:

const rotate = [0, 1, 2] => [ [0, 1, 2], [1, 2, 0], [2, 0, 1] ]

const rotate => ['a', 'b', 'c'] => [ ['a', 'b', 'c'], ['b', 'c', 'a'], ['c', 'a', 'b'] ]

You can do it!

Algorithms
Arrays

Stats:

CreatedMay 31, 2023
Warriors Trained15
Total Skips0
Total Code Submissions31
Total Times Completed12
JavaScript Completions12
Total Stars0
% of votes with a positive feedback rating36% of 7
Total "Very Satisfied" Votes2
Total "Somewhat Satisfied" Votes1
Total "Not Satisfied" Votes4
Total Rank Assessments7
Average Assessed Rank
7 kyu
Highest Assessed Rank
6 kyu
Lowest Assessed Rank
8 kyu
Ad
Contributors
  • PabloMatMar Avatar
Ad