Beta

RangeSet

Description
Loading description...
Algorithms
View
AllIssues6QuestionsSuggestions2Show Resolved
  • Please sign in or sign up to leave a comment.
  • dfhwze Avatar

    Duplicate of at least 2 other kata's about ranges. And those kata's are published, without any issues, and with added performance constraints.

  • dfhwze Avatar

    The most naieve solutions pass this kata, making this kata no challenge at all.

  • dfhwze Avatar

    Random tests are floating point numbers, but description says all numbers are integers. Btw floating point numbers are a horrible idea. How will you assess ranges that "meet" with truncation and rounding errors in floating points?

  • Blind4Basics Avatar

    Hi,

    The tests have to be rewritten one more time:

    • using Node10+
    • Not using expect, or the assertion message has to provide expected/actual values too
    • Not using somethign like assertSimilar
    • missing random tests

    The description needs a sweep too: r.ranges == [1, 2] [4, 6] [8, 9] -> this kind of thing has no meaning as a JS code.

    cheers

  • B1ts Avatar

    Great kata! Seems like your update invalidated every solution that was there :D

    There is a mistake in description: r.add(4, 6); // . 2 3 4 . . . . . ( should be r.add(2, 4) ? )

  • wthit56 Avatar

    Huge update! There was a lot of problems with the description, the tests, and even my own solution. Looks like all the existing solutions have been made invalid by the more complete tests, unfortunately. But you should still be able to access the code, if you're interested in tweaking your solution to fit the revised tests.

    As far as I can tell, the spec hasn't changed apart from cutting out some of the stuff that wasn't necessary (eg. invalid argument handling). All the functionality should be the same. All that's changed are the tests.

  • JohanWiltink Avatar

    Description consistently specifies "numbers". Is there testing with numbers other than integers? If not, might as well specify integers.

    Kata IMO goes too far in requiring certain internals. If I can make .test() behave correctly, why should .ranges be what you think it should be? It must apparently even be sorted a certain way. Why not leave that to solver?

    Example tests would be nice.

  • Voile Avatar

    Needs random tests and much bigger possible range.

  • Voile Avatar

    Descriptions:

    new RangeSet(from, to);

    But this case is not tested at all.

  • laoris Avatar

    This comment has been hidden.

  • laoris Avatar

    Nice kata, wthit; I enjoyed doing it, but there were a few oddities that initially led to some major confusion for me:

    1. the description for the ranges array says it should contain "range objects" which I thought meant instances of the Range class (especially since later in the kata description the phrase "range object" is used to refer to a Range instance),
    2. the constructor accepts from and to arguments, the same properties that should be on the "range objects" in the ranges array,
    3. in the initial solution, the ranges array is on the prototype instead of initialized in the constructor, and
    4. the class is named singular Range.

    The above all led me to think that the ranges array was some kind of weird class-wide array, instances of Range were the range objects in that array, and each instance of Range was supposed to add itself to that array.

    Obviously that doesn't make sense, and this was a bit of a derp moment for me, but I do think the kata could be made clearer if:

    1. the initial solution was fixed so the ranges array is initialized in the constructor instead of on the prototype,
    2. the class was renamed Ranges to reflect that it contains multiple ranges, and
    3. instead of the constructor accepting from and to parameters, it optionally accepted another Ranges instance to initialize itself with (by copying the ranges from the given instance).

    I think #1 is a must-fix, but the other two are a bit more opinionated, borne of my experience above, so it's up to you!