Ad
  • Custom User Avatar

    Ok I'll add that. Done.

  • Default User Avatar

    I think cause when I was writing it, my mindset was on expected should always = output of the method.
    which is why I was surprised to see Expected = the original input cause my mind was like
    "But the whole point of the method is to remove the smallest number!" that's why

  • Default User Avatar

    Current test message:
    You've mutated input array

    Wonder if this will be clearer?
    You've mutated input array (expectation assertion is on value of input array, not output of method)

  • 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]
    
  • Default User Avatar

    Maybe the test expectation message can be more accurate? I thought the expectation was the output of the method, which was what confused me.

  • Default User Avatar

    ahh right thanks - i took that to mean don't mutate the order

  • 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

    Sorry should have been clearer - this is with the mutations to original array test

  • Default User Avatar
    > check for mutations to original array
    Log
    Direct input is [147, 376, 340, 233, 281, 322, 132, 128]
    
    You've mutated input array -  
    Expected: [147, 376, 340, 233, 281, 322, 132, 128], 
    instead got: [147, 376, 340, 233, 281, 322, 132]
    

    What I don't understand is: If the direct input is [147, 376, 340, 233, 281, 322, 132, 128], I would expect the smallest number '128' to be removed - but it seems the expectation does not expect this

  • 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.

  • Default User Avatar

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

  • Default User Avatar

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