microsoft/qdk

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
joaoboechat/remove-web-worker-dependency

Branches

Tags

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

Clone

HTTPS

Download ZIP

katas/content/complex_arithmetic/complex_modulus/Verification.qs

24lines · modecode

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