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.
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.
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.
That means
[1, 2, 4, 5, 6]
is"1,2,4-6"
and not"1-2,4-6"
.-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.11 and 14 aren't consecutive numbers, so, obviously, the range ends in 11.
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.
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.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: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 whenindex - 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.-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.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 after3-5
, but then it swallows a whole 5 numbers, and abandons15
.17-20
fortunately heralds the end of this hamster wheel of reasoning, but not before mysteriously consuming four numbers.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
variable name isnt assigned any value, i dont get why it needs to be there...?
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.
TS:
it
block messages should beTesting with ${JSON.stringify(word)}
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!
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.
NO random tests in Groovy
Yes, this happens when code is wrong.
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??????????????????????????????????????????????????????????
"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...