Ad
  • Custom User Avatar

    Doesn't it says at least 3 numbers there? Meaning three or more? IMHO you're saying the same, but I can be wrong and maybe one way of writing it is clearer than the other.

  • Default User Avatar

    I must admit my critique was a bit exagerated, but this is the first kata out of a hundred odd that I've struggled this much to grasp. I see now, with Diego's help and diagram, although not really with his explanation, hehe, how this one is supposed to work.

    It seems to me that this kata is explained from the point of view of a consumer of such a list, as then it is abundantly clear. Maybe other people might also benefit from it being more clear that 3 numbers is a minimum size of a range and it should ne more whenever possible.

  • Custom User Avatar

    It is not considered a range unless it spans at least 3 numbers

    That means [1, 2, 4, 5, 6] is "1,2,4-6" and not "1-2,4-6".

    None of the consecutive elements at positions 0,1, and 2 differ by more than 1

    -10, -9 and -8 form this range: "-10--8". I think you're confusing what should be consecutive as a number and as an element in the list.

    solution([-10, -9, -8, -6, -3, -2, -1, 0, 1, 3, 4, 5, 7, 8, 9, 10, 11, 14, 15, 17, 18, 19, 20]);
              |         |   |  |              |  |     |  |             |   |   |  |            |
              -----------   |  ----------------  -------  ---------------   |   |  --------------
                "-10--8   ,-6,         -3-1,       3-5,         7-11,      14, 15,      17-20"
    

    7-11 starts out well, 1 position after 3-5, but then it swallows a whole 5 numbers, and abandons 15.

    11 and 14 aren't consecutive numbers, so, obviously, the range ends in 11.

    The range 17-20 fortunately heralds the end of this hamster wheel of reasoning, but not before mysteriously consuming four numbers.

    There is no mistery there, it says at least 3 numbers, there can be more.

    I'd close this, because I think it all comes to your misunderstanding of the instructions, which are fine be me.

  • Custom User Avatar

    The goal is to group all numbers adjacent in the list which differ at most by 1. In your example of [-9, -8, -6], two last numbers do not differ by 1. If you have an idea for a better wording, feel free to suggest one.

  • Default User Avatar

    The description for this kata is unclear. It says, It is not considered a range unless it spans at least 3 numbers. For example "12,13,15-17", but then the example solution shows this:

    solution([-10, -9, -8, -6, -3, -2, -1, 0, 1, 3, 4, 5, 7, 8, 9, 10, 11, 14, 15, 17, 18, 19, 20]);
    // returns "-10--8,-6,-3-1,3-5,7-11,14,15,17-20"
    

    None of the consecutive elements at positions 0,1, and 2 differ by more than 1, yet the return value shows -10--8 as a range. Yes, the slice [-1, -9, -8] itself spans 3 numbers, but so do [-9, -8, -6]and [-8, -6, -3] etc. Maybe we're supposed to start at "peg" 0 and when index - 0 >= 3 we have the range -10--8. In that case, it only makes sense to resume with index 3, or -6. but then I would expect the next range to be -6--2, or -6--1, depending if the author uses high or low values for of 3.

    • The next range is mysteriously -3-1, with -6 being left all on its ownsome. This one now spans 5 numbers, where my delusion was that ranges spanned 3 numbers.
    • At least 3-5 starts where I expect it to, directly after the previous range, and it spans 3 numbers, as claimed.
    • 7-11 starts out well, 1 position after 3-5, but then it swallows a whole 5 numbers, and abandons 15.
    • The range 17-20 fortunately heralds the end of this hamster wheel of reasoning, but not before mysteriously consuming four numbers.
  • Custom User Avatar

    I really gotta start looking up functions for Python before I assume there isn't one for that exact task because there's a 98% chance there is

  • Custom User Avatar

    variable name isnt assigned any value, i dont get why it needs to be there...?

  • Default User Avatar

    You should add tests to this kata to check the function for working with arrays of one element. The solution of some participants (e.g. ElectroYan user) returns the correct result when using a multi-item array as an argument, but returns the wrong result when using a single-item array as an argument.
    This problem was found in the C# version, but I think it's the same in versions for other languages.

  • Custom User Avatar

    TS: it block messages should be Testing with ${JSON.stringify(word)}

  • Default User Avatar

    Ive noticed you are a mod,you should put a warning the code doesnt work on the attempts if you are registering your incrementations in the log due to lack of space, thanks in advance!

  • Default User Avatar

    I would gladly take a look at your code. Also this code doesnt work if you register the increments in a console.log,aparently it breaks the console due to lack of space.

  • Custom User Avatar

    NO random tests in Groovy

  • Custom User Avatar

    Yes, this happens when code is wrong.

  • Default User Avatar

    my code is working and giving correct output on my vs code but when i am entering the same code here its gives error and wrong output??????????????????????????????????????????????????????????

  • Custom User Avatar

    "faster" is true; "more effective" depends on the desired effect. Depending on your stdout, the behavior of the two is different, since endl forces a buffer flush.

  • Loading more items...