microsoft/qdk

Public

mirrored fromhttps://github.com/microsoft/qdkAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
iadavis/pipeline-issue-debugging

Branches

Tags

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

Clone

HTTPS

Download ZIP

katas/content/key_distribution/random_array/Verification.qs

34lines · modecode

1namespace Kata.Verification {
2 import Std.Arrays.*;
3 import Std.Convert.*;
4
5 @EntryPoint()
6 operation CheckSolution() : Bool {
7 // The test only checks that the operation returns an array of correct length
8 // and that it's not always the same. It doesn't analyze the distribution of true and false elements.
9 let N = 20;
10 let randomArrays = ForEach(Kata.RandomArray, [N, size = 10]);
11
12 for array in randomArrays {
13 if Length(array) != N {
14 Message($"Returned array should have length {N}, and it had length {Length(array)}.");
15 return false;
16 }
17 }
18
19 let randomInts = Mapped(BoolArrayAsInt, randomArrays);
20 mutable allSame = true;
21 for int in randomInts {
22 if int != randomInts[0] {
23 set allSame = false;
24 }
25 }
26 if allSame {
27 Message($"Random generation should not return a fixed array.");
28 return false;
29 }
30
31 Message("Correct!");
32 true
33 }
34}
35