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.
if w != (vmax && vmin)
compares w to a boolean value of vmax && vmin, and because w, vmax and vmin are all numbers it naturally doesn't work.
first, this is NOT an issue. It's just a question.
for your question, my answer is: perhaps you should not using delete in the
map!
loop. I guess it will skip some index(I'm not sure. because I don't know Ruby and I've not try your code)This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
delete
mutates the original array, and in general putting side effect code inside a pure list method (map) is never a good idea.You aren't using
match
properly:match
is a prototype method of String, not RegExp.Besides, this is not an issue.
This comment is hidden because it contains spoiler information about the solution
After each deletion the elements after the deleted one are shifted and the indices get offset too. It's not a kata issue. BTW, modifying input in-place is usually not expected unless explicitly asked for.
This comment is hidden because it contains spoiler information about the solution
Thanks! now it works! But why if the counter is above the "break if" the code do not found? why if the counter is above the break isn't checked?
Ruby should go down until the break to dheck when stop,doesn't it? or just go down until it find the counter?
Thanks
Oops, you put a double equals instead of a single equals. Change
counter == counter + 1
tocounter = counter + 1
This comment is hidden because it contains spoiler information about the solution
Actually, your code is wrong. You need to change your break statement to
counter == n+1
or need to put your counter increment after your break statement.Your counter variable exceeds the value of n. This is the reason why it takes so long, it's because you end up with an infinite loop, since it never reaches the break statement.
Example
This comment is hidden because it contains spoiler information about the solution