microsoft/qdk

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
v1.3.0

Branches

Tags

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

Clone

HTTPS

Download ZIP

katas/content/complex_arithmetic/complex_modulus/Verification.qs

22lines · modecode

1namespace Kata.Verification {
2 open Microsoft.Quantum.Math;
3
4 @EntryPoint()
5 operation CheckSolution() : Bool {
6 for _ in 0 .. 24 {
7 let x = DrawRandomComplex();
8
9 let expected = AbsComplex(x);
10 let actual = Kata.ComplexModulus(x);
11
12 if AbsD(expected - actual) > 1e-6 {
13 Message("Incorrect");
14 Message($"For x = {ComplexAsString(x)} expected return {expected}, actual return {actual}.");
15 return false;
16 }
17 }
18
19 Message("Correct!");
20 return true;
21 }
22}
23