From 338d692ea721fec8a7f1bfabbe9982ff88af7577 Mon Sep 17 00:00:00 2001 From: Kory Becker Date: Tue, 7 Dec 2021 22:33:36 -0500 Subject: [PATCH] up --- README.md | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 727e1b0..2519f93 100644 --- a/README.md +++ b/README.md @@ -499,6 +499,14 @@ To construct an oracle for this application, we only need to be able to find a s In the above examples for even and odd numbers, we knew exactly which qubit to flip (qubit 0). This time, we need to flip [specific](https://github.com/primaryobjects/oracle/blob/master/lib/oracles/numeric.py) qubits, based upon the target value. This can be done by converting the value from base-10 to a binary string and then flipping the resulting qubits accordingly to their corresponding bit values. ```python +# Choose a (random) target answer. +i = 6 + +# Convert i to a binary string, pad with zeros, and reverse for qiskit. +bin_str = bin(i)[2:] +bin_str = bin_str.zfill(n) +bin_str = bin_str[::-1] + # Flip each qubit to zero to match the bits in the target number i. for j in range(len(bin_str)): if bin_str[j] == '0': @@ -506,7 +514,6 @@ for j in range(len(bin_str)): qc.append(ZGate().control(n), range(n+1)) - # Unflip each qubit to zero to match the bits in the target number i. for j in range(len(bin_str)): if bin_str[j] == '0':