Ad
  • Default User Avatar

    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.

  • Custom User Avatar

    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)

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    delete mutates the original array, and in general putting side effect code inside a pure list method (map) is never a good idea.

  • Custom User Avatar

    You aren't using match properly: match is a prototype method of String, not RegExp.

    Besides, this is not an issue.

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Default User Avatar

    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.

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    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

  • Default User Avatar

    Oops, you put a double equals instead of a single equals. Change counter == counter + 1 to counter = counter + 1

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    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

    power_of_two(0)
    
    loop do                  #first loop
      counter = 0 + 1
      
      break if 1 == 0
    end
    
  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution