microsoft/qdk

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
amcasey/ArrayWrap

Branches

Tags

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

Clone

HTTPS

Download ZIP

katas/content/complex_arithmetic/complex_conjugate/Verification.qs

27lines · modecode

1namespace Kata.Verification {
2 import Std.Math.*;
3
4 function ComplexConjugate_Reference(x : Complex) : Complex {
5 // Return the complex conjugate
6 Complex(x.Real, -x.Imag)
7 }
8
9 @EntryPoint()
10 operation CheckSolution() : Bool {
11 for _ in 0..24 {
12 let x = DrawRandomComplex();
13
14 let expected = ComplexConjugate_Reference(x);
15 let actual = Kata.ComplexConjugate(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