Ad
  • Custom User Avatar

    Ok I'll add that. Done.

  • Custom User Avatar

    What's your suggestion? As you can see:

    check for mutations to original array                           // This is what's been tested
    Log                                                             // This log is part of your code 
    Direct input is [147, 376, 340, 233, 281, 322, 132, 128]
    
    You've mutated input array -                                    // This is the error message
    Expected: [147, 376, 340, 233, 281, 322, 132, 128], 
    instead got: [147, 376, 340, 233, 281, 322, 132]
    
  • Custom User Avatar

    It seems you didn't read/understood this part of the instructions:

    Do not mutate the original array/list.

    That test is only for testing input mutation, it's not like the others.

  • Default User Avatar

    The ruby code is fine. I ran this to check the functionality as described.:

    def remove_smallest(numbers)
      p numbers
      [42, 42, 42, 42]
    end
    

    And the results show that the input is not exactly the same as the expected output :

    works for the examples
    Log
    [1, 2, 3, 4, 5]
    Wrong result for [1, 2, 3, 4, 5] -  Expected: [2, 3, 4, 5], instead got: [42, 42, 42, 42]
    
    works for random arrays
    Log
    [145, 395, 50, 206, 274, 5, 240, 140, 23]
    Wrong result for [145, 395, 50, 206, 274, 5, 240, 140, 23] -  Expected: [145, 395, 50, 206, 274, 240, 140, 23], instead got: [42, 42, 42, 42]
    

    Also, take note that there are 2,661 solutions in ruby for this kata, so any such bug would have been discovered long ago.