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.
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.
C# Translation
Java:
tests emit warnings to STDERR:
Note: src/test/java/Tests.java uses unchecked or unsafe operations.
because of this line:
(CircularList is a raw type and needs to be parameterized).
is really misleading, since literally
throw
ing anew Exception()
does not compile, as it is a checked exception and the tests do notcatch
it.In the initial code, the constructor of
CircularList
should probably be annotated with@SafeVarargs
to avoid a warning.Julia translation