C# - Roll the Die! - Task 1

Hi, guys!

The exercise that is mentioned in the topic’s subject is about randomness and I think there might be a small issue in Task 1 and its test case.

In Task 1, a random number between 1 and 18 should be generated (1 and 18 should also be accepted).

In my opinion the test case doesn’t cover fully the possible solution for the task because it doesn’t check the edge cases. When someone uses the built-in Next() function like this: random.Next(1, 18), it never generates the number 18, but the test case passes.

I think paying attention to the exclusive upper bound is a critical point in this exercise and learning randomness.

I also reported the bug in the Editor view a while ago but a discussion here might be more useful.

Any thoughts, guys?

One problem with testing generated random values is: There is no guarantee to produce the boundary values (or any other value) in a given amount of rounds. So, a doesGenerate18() test might have to run forever(*) before 18 actually would be returned.

(*) There is a timeout of 20 seconds in place at Exercism.

Well, yes, it’s non-deterministic. However, the existing test case is still misleading, as you can see in many of the published solutions.

Exercism offers mentoring for hints about such issues in ones solution. But as everything in exercism is a choice made by students, there are many people that don’t ask for mentoring.

The community solutions are like everything else on the internet: what others have published, may or may not be a good solution to your problem. If you use ChatGPT, Google or StackOverflow, you must understand what they offer. We can’t help people with learning that.

1 Like