Ad
  • Custom User Avatar

    I'm also a big fan of not using magic numbers. Even in a "simple one-liner".

  • Custom User Avatar

    May I ask why? I'm guessing you'd rather store p0 in a new variable and work with that instead but I'm curious as to your reasoning if the function is only small like this one.

  • Custom User Avatar

    You're removing those numbers from the input, so, when the control function calculates its sum, it's using the other numbers: 136 + 128 + 83 = 347 Anyways, I've changed the tests so the expected value is computed first and your code messing with the input isn't a problem anymore, but be aware of that.

  • Custom User Avatar

    Thanks for the reply but I don't understand. The description says, "your task is to find the sum of the minimum values in each row."

    As I understand it, the minimum values of each row in the above test are 49, 82 and 17, of which the sum is 148, not 347. What am I missing?

  • Custom User Avatar

    Don't mutate the input.

  • Custom User Avatar

    All of the random tests failed for me. One of the tests tested for [[49, 136],[128,82],[17,83]]. It failed telling me 'Expected 148 to equal 347'. So 49 + 82 + 17 = 347? Or have I grossly misunderstood something?

  • Default User Avatar

    In bigger projects i would expect such constants. That is much better, than 'magic' 0.5. But if we want just simple function... =)

  • Custom User Avatar

    I notice most solutions I've seen here so far tend not to declare interim variables such as:

    const litersPerHour = 0.5;

    Wondering what your thoughts are on using them vs omiting them?