Just before the contribution policy change, I’ve created a test that should cover an edge case which a great portion of the community solutions do not cover.
Link to original PR: here
By accident, I’ve chosen a battery and trackDistance combination that actually does not trigger the wrong behavior. I wanted to fix this test case in a new PR, but this is not possible anymore.
This issue would be fixed with the following test:
{
name: "Car has 60% battery. Car cannot finish the race",
car: Car{
speed: 3,
batteryDrain: 3,
battery: 60,
},
trackDistance: 61,
expected: false,
},
instead of this one:
{
name: "Car has 50% battery. Car cannot finish the race",
car: Car{
speed: 3,
batteryDrain: 3,
battery: 50,
},
trackDistance: 51,
expected: false,
},
I was able to mark your reply as solution.
Thank you so much! I just wanted to make sure other people solving this exercise don’t make the same error as I did. Now it works for sure!
I am not sure why these approaches lead to differing results. How much battery do you need to cover a given distance vs how much distance can you cover with the given battery? Are we just in luck that the test only uses ints and division does not result in floating points in the passing solution? I would appreciate some insights into the reasoning behind the test.