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
Seems the result should be a number, not a string. It is cernainly intended to be used in further calculations (if we forget it's just a training).
Also it is highlighted in kata code "return 0;".
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.But this is a perfectly valid protocol for circular lists? One of a few possible, but still, a good one. It is also very clearly defined and well described.
Why on Earth first next() invocation gives first element (not second), but first prev() invocation gives last element? The behavior of next() is not consistent! Just delete this kata. Why there is a place for bad design and teaching of bad practices on this site?
it seems to have been fixed
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
s.lines()
is twice slower thans.split("\n")
Kotlin!
Use init for generating Exception.
What language is this? It should just be expecting that an exception is thrown if an empty list is created.
I still don't understand what the empty test is expecting, and how to check it.
enjoyable kata ...
It was kotlin
Loading more items...