Go Track - Need for Speed - suggestion for a test scenario

Hi all,

I’ve recently solved the Need for Speed challenge and realised it’s missing an important testing use-case for the CanFinish function.

The README #4 reads:

Assume that you are currently at the starting line of the race and start the engine of the car for the race. Take into account that the car’s battery might not necessarily be fully charged when starting the race:

Assume you’re currently at the starting line, but in the test scenarios, cars not always start at distance: 0.

{
	name: "Car can easily finish the track distance.",
	car: Car{
		speed:        5,
		batteryDrain: 2,
		battery:      100,
		distance:     20,
	},
	track: Track{
		distance: 30,
	},
	expected: true,
},

However, if the car.distance is not zero, that means the car is not in the starting line when this function is called. As it says “the starting line”, most of community solutions - mine included - did not consider the car.distance at all when implementing the function. But if the car could be anywhere in the track, then I suggest replacing the current instructions to something like this:

Assume that you are anywhere in the track, either the starting line or just before crossing the finish line.

And the test updated to:

{
	name: "Car can easily finish the track distance.",
	car: Car{
		speed:        5,
		batteryDrain: 5,
		battery:      10,
		distance:     90,
	},
	track: Track{
		distance: 100,
	},
	expected: true,
},

That car would make, but depending on how the function is implemented it won’t return true.

Hope that makes sense.

Thanks all! :slight_smile:

  • Does this change fix something which is broken?
  • Does this change better help students better learn the concept (structs)?
  • Is this change worth breaking all the published solutions?

To be clear, I appreciate the input and suggestion and think it has merit! And, to be clear, I’m not a Go track maintainer. These are just some questions that may be worth thinking about and guessing at when suggesting this type of change.

Hey @IsaacG

Yeah, that makes sense. I don’t think it would help students better learn the concept. I think it’s more like a cohesion thing. The instructions would be coherent with what we see in the test scenarios. It’s also important to write relevant and coherent tests too.

But I do agree it’s not worth breaking the published solutions if it’s not wrong nor helpful for the purpose of the challenge.

If you guys think it’s worth it, perhaps a middle ground would be updating the Challenge description only. That wouldn’t break any solution. Please ignore this if it’s just not relevant at all.

Thanks for the reply! :slight_smile:

As the tests and the description seem to mismatch, changing the instructions would seem to add clarity. If we can avoid changing the tests, that would be good.

(cc @andrerfcsantos)

1 Like