Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Need for speed exercise CanFinish tests do not validate start with distance travelled #2740

Closed
seriar opened this issue Jan 10, 2024 · 1 comment

Comments

@seriar
Copy link

seriar commented Jan 10, 2024

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

  1. Rephrase the can finish the race to can finish the race from start to finish to make it a bit clearer, and
  2. 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

  1. 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
  2. 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,
		},
Copy link
Contributor

Hello. Thanks for opening an issue on Exercism 🙂

At Exercism we use our Community Forum, not GitHub issues, as the primary place for discussion. That allows maintainers and contributors from across Exercism's ecosystem to discuss your problems/ideas/suggestions without them having to subscribe to hundreds of repositories.

This issue will be automatically closed. Please use this link to copy your GitHub Issue into a new topic on the forum, where we look forward to chatting with you!

If you're interested in learning more about this auto-responder, please read this blog post.

seriar added a commit to seriar/go that referenced this issue Jan 10, 2024
- requiring and testing that `CanFinish` handles the case of battery <
  batteryDrain as `Drive` function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant