microsoft/qdk

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
v1.3.0

Branches

Tags

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

Clone

HTTPS

Download ZIP

katas/content/random_numbers/random_two_bits/Solution.qs

12lines · modecode

1namespace Kata {
2 open Microsoft.Quantum.Measurement;
3 operation RandomTwoBits() : Int {
4 return 2 * RandomBit() + RandomBit();
5 }
6
7 operation RandomBit() : Int {
8 use q = Qubit();
9 H(q);
10 return MResetZ(q) == Zero ? 0 | 1;
11 }
12}
13