microsoft/qdk

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
iadavis/pipeline-issue-debugging

Branches

Tags

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

Clone

HTTPS

Download ZIP

katas/content/key_distribution/random_array/solution.md

10lines · modepreview

You need to do three steps to generate an array of random values:

1. Create a mutable array of size $N$ - it will need a default value that can be `false`.
2. For each index from $0$ to $N-1$, choose one of the two values `true` or `false` at random, and assign that value to the array element at that index. You could choose a random bit by allocating a qubit, preparing it in the $\ket{+}$ state, and measuring it. However, you don't need those bits to have quantum origin, so you can use a Q# library operation `DrawRandomInt` instead.
3. Finally, return the generated array.

@[solution]({
    "id": "key_distribution__random_array_solution",
    "codePath": "./Solution.qs"
})