microsoft/qdk

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
v1.14.0

Branches

Tags

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

Clone

HTTPS

Download ZIP

katas/content/complex_arithmetic/complex_exponents/Verification.qs

27lines · modecode

1namespace Kata.Verification {
2 import Std.Math.*;
3
4 function ComplexExponent_Reference(x : Complex) : Complex {
5 let expa = E()^x.Real;
6 return Complex(expa * Cos(x.Imag), expa * Sin(x.Imag));
7 }
8
9 @EntryPoint()
10 operation CheckSolution() : Bool {
11 for _ in 0..24 {
12 let x = DrawRandomComplex();
13
14 let expected = ComplexExponent_Reference(x);
15 let actual = Kata.ComplexExponent(x);
16
17 if not ComplexEqual(expected, actual) {
18 Message("Incorrect");
19 Message($"For x = {ComplexAsString(x)} expected return {ComplexAsString(expected)}, actual return {ComplexAsString(actual)}.");
20 return false;
21 }
22 }
23
24 Message("Correct!");
25 return true;
26 }
27}
28