Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
This comment is hidden because it contains spoiler information about the solution
The definition of this problem can be improved. By the current definition,
next()
returns1
andprev()
returns5
given the first example of[1..5]
. This implies that the pointer is "between" the last and first elements, a state it will never find itself in again. This makes the solution more convoluted and difficult to reason about.I suggest specifying that in the initial state
next()
returns2
andprev()
returns5
. Alternatively, ifnext()
returns1
,prev()
can return4
.Another option is to take the initial "selected element" as input in the constructor.