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

Captain's Log, typo in the instructions or error in the test for task 2 #2589

Closed
ghost opened this issue Nov 28, 2023 · 1 comment · Fixed by #2588
Closed

Captain's Log, typo in the instructions or error in the test for task 2 #2589

ghost opened this issue Nov 28, 2023 · 1 comment · Fixed by #2588

Comments

@ghost
Copy link

ghost commented Nov 28, 2023

Hi,

That challenge was funny to solve. Really great exercise to work with random number :)

For the task 2, you ask to generate a registry number that starts with the prefix "NCC-" and then uses a number from 1000 to 9999 (inclusive).

So that code should validates the challenge. return String.format("NCC-%d", 1000 + this.random.nextInt(9000));

But it doesn't. I had to subtract 1 from 9000 to pass the tests. That means the result is a random number in this range [1000 - 9998] and not [1000 - 9999].

So:

  • or there's a typo in the instructions and it's not 9999 (inclusive) but 9999 (exclusive)
  • or the unit test is wrong. The upper bound of this assertion at line 63 is exclusive.

WDYT?

@sanderploegsma
Copy link
Contributor

That challenge was funny to solve. Really great exercise to work with random number :)

Thanks!

And thank you for the feedback. This was also mentioned on the forum today: https://forum.exercism.org/t/issues-with-captains-log-exercise/8412. It's a mistake in the tests; I used my own example solution to find the expected numbers for the seeds used in the tests, but my example solution contains a bug...

It should be fixed by #2588, FYI.

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

Successfully merging a pull request may close this issue.

1 participant