Skip to content

Instantly share code, notes, and snippets.

@stevenheidel
Last active August 25, 2020 17:07
Show Gist options
  • Save stevenheidel/15a7ff8b2613e16d3896f2fc4d446563 to your computer and use it in GitHub Desktop.
Save stevenheidel/15a7ff8b2613e16d3896f2fc4d446563 to your computer and use it in GitHub Desktop.
medium-braket-5.py
from braket.circuits import Circuit
from braket.aws import AwsDevice
import time
s3_folder = ("[insert s3 bucket name]", "simulation-output")
device = AwsDevice("arn:aws:braket:::device/qpu/rigetti/Aspen-8")
coin_flip_circuit = Circuit().h(0)
task = device.run(coin_flip_circuit, s3_folder, shots=10)
while task.state() in ['CREATED', 'QUEUED']:
print(time.ctime(), 'Waiting...')
time.sleep(60)
result = task.result()
if result.measurements[0][0] == 1:
print("HEADS!")
else:
print("TAILS!")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment