Ad
  • Custom User Avatar

    The definition of this problem can be improved. By the current definition, next() returns 1 and prev() returns 5 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() returns 2 and prev() returns 5. Alternatively, if next() returns 1, prev() can return 4.

    Another option is to take the initial "selected element" as input in the constructor.

  • Custom User Avatar
  • Custom User Avatar

    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;".

  • Custom User Avatar

    Java:

    • tests emit warnings to STDERR:
      Note: src/test/java/Tests.java uses unchecked or unsafe operations.

      because of this line:

      public void emptyListTest() {
        new CircularList();
      }
      

      (CircularList is a raw type and needs to be parameterized).

    • Your list constructor/init code should throw an Exception if nothing is passed in.

      is really misleading, since literally throwing a new Exception() does not compile, as it is a checked exception and the tests do not catch it.

    • In the initial code, the constructor of CircularList should probably be annotated with @SafeVarargs to avoid a warning.

  • Custom User Avatar

    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.

  • Custom User Avatar

    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?

  • Custom User Avatar

    it seems to have been fixed

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    s.lines() is twice slower than s.split("\n")

  • Custom User Avatar

    Kotlin!
    Use init for generating Exception.

  • Custom User Avatar

    What language is this? It should just be expecting that an exception is thrown if an empty list is created.

  • Custom User Avatar

    I still don't understand what the empty test is expecting, and how to check it.

  • Custom User Avatar

    enjoyable kata ...

  • Custom User Avatar

    It was kotlin

  • Loading more items...