Closed
Description
There are two slightly ambiguous parts about the CanFinish
subtask:
Calling CanFinish
with car.distance > 0
Problem
There is a line in instructions implying that the distance traveled by car before the function call should not be use for the check:
Assume that you are currently at the starting line of the race
But the tests do not validate it so both implementations counting and not counting it towards the track distance
Suggestion
- Rephrase the
can finish the race
tocan finish the race from start to finish
to make it a bit clearer, and - add a test validating that
car.distance
is not counted towards the target distance
{
name: "Car cannot finish the track distance with initial battery less than 100% and traveled distance is not 0",
car: Car{
speed: 4,
batteryDrain: 5,
battery: 25,
distance: 1,
},
track: Track{
distance: 21,
},
expected: false,
},
Travelling with battery < batteryDrain
Problem
The instructions for Drive
function indicate that it should not be possible to travel with a battery level lower the battery drain rate. But the tests for CanFinish
do not validate it. So one can write a solution that would allow it, and still pass all the tests.
Suggestion
- Clarify the requirement with
Car cannot travel at all if the battery level is less than batteryDrain
(or the opposite but that is a bit more tricky) and - add a test validating that part of the speed is never taken
{
name: "Car cannot finish with partial move (part of batteryDrain)",
car: Car{
speed: 2,
batteryDrain: 200,
battery: 100,
distance: 0,
},
track: Track{
distance: 1,
},
expected: false,
},
Metadata
Metadata
Assignees
Labels
No labels