microsoft/qdk

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
alex/pythontelem

Branches

Tags

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

Clone

HTTPS

Download ZIP

katas/content/complex_arithmetic/polar_to_cartesian/Verification.qs

23lines · modecode

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