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)delete
mutates the original array, and in general putting side effect code inside a pure list method (map) is never a good idea.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.
Oops, you put a double equals instead of a single equals. Change
counter == counter + 1
tocounter = counter + 1
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