Created
July 1, 2017 15:24
-
-
Save jeffrafter/c35286bbcf0c08376de935dac47f3c87 to your computer and use it in GitHub Desktop.
Flip a coin on Forest Quantum Virtual Machine
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pyquil.quil as pq | |
import pyquil.api as api | |
from pyquil.gates import * | |
coin_flip = pq.Program().inst(H(0)).measure(0, 0) | |
num_flips = 5 | |
qvm = api.SyncConnection() | |
flips = qvm.run(coin_flip, [0], num_flips) | |
# Should see [[0], [1], [0], [1], [0]] (the results will change!) | |
print(flips) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment