Skip to content

Commit

Permalink
Added DoubleAsStringWithPrecision function - Single Qubit Gate (#1884)
Browse files Browse the repository at this point in the history
Added DoubleAsStringWithPrecision function to Single Qubit Gate Kata

This is to address the issue #1788
  • Loading branch information
devikamehra authored Aug 29, 2024
1 parent cf36843 commit 58a54ca
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ namespace Kata.Verification {
let reference = register => AmplitudeChange(alpha, register[0]);
let isCorrect = CheckOperationsAreEqualStrict(1, solution, reference);
if not isCorrect {
let precision = 3;
Message("Incorrect.");
Message($"The solution was incorrect for the test case alpha = {alpha}.");
Message($"The solution was incorrect for the test case alpha = {DoubleAsStringWithPrecision(alpha, precision)}.");
Message("Hint: examine the effect your solution has on the state 0.6|0〉 + 0.8|1〉 and compare it with the effect it " +
"is expected to have.");
ShowQuantumStateComparison(1, qs => Ry(ArcTan2(0.8, 0.6) * 2.0, qs[0]), solution, reference);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ namespace Kata.Verification {
let reference = register => PhaseChange(alpha, register[0]);
let isCorrect = CheckOperationsAreEqualStrict(1, solution, reference);
if not isCorrect {
let precision = 3;
Message("Incorrect.");
Message($"The solution was incorrect for the test case alpha = {alpha}.");
Message($"The solution was incorrect for the test case alpha = {DoubleAsStringWithPrecision(alpha, precision)}.");
Message("Hint: examine the effect your solution has on the state 0.6|0〉 + 0.8|1〉 and compare it with the effect it " +
"is expected to have.");
ShowQuantumStateComparison(1, qs => Ry(ArcTan2(0.8, 0.6) * 2.0, qs[0]), solution, reference);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ namespace Kata.Verification {
let reference = register => PrepareArbitraryState(alpha, beta, theta, register[0]);
let isCorrect = CheckOperationsEquivalenceOnZeroStateStrict(solution, reference, 1);
if not isCorrect {
let precision = 3;
Message("Incorrect.");
Message($"The solution was incorrect for the test case alpha = {alpha}, beta = {beta}, theta = {theta}.");
Message($"The solution was incorrect for the test case alpha = {DoubleAsStringWithPrecision(alpha, precision)}, beta = {DoubleAsStringWithPrecision(beta, precision)}, theta = {DoubleAsStringWithPrecision(theta, precision)}.");
Message("Hint: examine the state prepared by your solution and compare it with the state it " +
"is expected to prepare.");
ShowQuantumStateComparison(1, qs => (), solution, reference);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ namespace Kata.Verification {
let reference = register => PrepareRotatedState(alpha, beta, register[0]);
let isCorrect = CheckOperationsEquivalenceOnZeroStateStrict(solution, reference, 1);
if not isCorrect {
let precision = 3;
Message("Incorrect.");
Message($"The solution was incorrect for the test case alpha = {alpha}, beta = {beta}.");
Message($"The solution was incorrect for the test case alpha = {DoubleAsStringWithPrecision(alpha, precision)}, beta = {DoubleAsStringWithPrecision(beta, precision)}.");
Message("Hint: examine the state prepared by your solution and compare it with the state it " +
"is expected to prepare.");
ShowQuantumStateComparison(1, qs => (), solution, reference);
Expand Down

0 comments on commit 58a54ca

Please sign in to comment.