microsoft/qdk

Public

mirrored from https://github.com/microsoft/qdkAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
dmitryv/select-updated

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

katas/content/random_numbers/random_n_bits/verification.qs

21lines · modecode

1namespace Kata.Verification {
2 @EntryPoint()
3 operation CheckSolution() : Bool {
4 // Test random number generation for 1, 2, 3, 10 bits
5 let testCases = [(1, 1000), (2, 1000), (3, 1000), (10, 10000)];
6 for (N, runs) in testCases {
7 Message($"Testing N = {N}...");
8 let max = (1 <<< N) - 1;
9 let randomnessVerifier = () => CheckUniformDistribution(() =>
10 Kata.RandomNBits(N), 0, max, runs);
11 let isCorrect = IsSufficientlyRandom(randomnessVerifier);
12 if not isCorrect {
13 return false;
14 }
15 Message($"Test passed for N = {N}");
16 }
17 Message("All tests passed.");
18 true
19 }
20
21}
22