This is not two random rolls. The second number will never match the first, so the statistical distribution is not correct, although the test suite is not sophisticated enough to catch it.
@Dyuman Monte Carlo would probably work: call the function 1e4 times, check how often the two rolls are the same, and test whether the result is (statistically) significantly different from the expected value. Setting a very high significance level to avoid false positives would allow valid solutions to pass with a very high probability while catching ones such as this.
Group
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
This is not two random rolls. The second number will never match the first, so the statistical distribution is not correct, although the test suite is not sophisticated enough to catch it.
^Agreed.
Making a sophisticated test suite for such case(s) seems to be an interesting challenge!
@Dyuman Monte Carlo would probably work: call the function 1e4 times, check how often the two rolls are the same, and test whether the result is (statistically) significantly different from the expected value. Setting a very high significance level to avoid false positives would allow valid solutions to pass with a very high probability while catching ones such as this.