may4_challenge_exercises
may4_challenge_exercises copied to clipboard
I am very confused whatever gate should use here.
def bob_measure_qubit(bob_bases, qubit_index, qubit_circuit): # # # insert your code here to measure Alice's bits
Hi, If you want to perform a measurement in the standard basis, you don't have to use any gate. But for the measurement in the (|+>, |->) basis you must apply a H gate before measuring, this perform a projection of your state in this basis.
Yes, the normal measure method measures in |0>,|1> basis. To measure in |+>, |-> basis one needs to apply the Hadamard gate to convert it in |0>,|1> respectively and then use the measuring method.
Hi, could somebody please give me some other hint here?
I think I completely misunderstood some main part of BB84. I'm currently deciding on what gate (Hadamard versus none) will be used in bob_measure_qubit
before the measurement based on bob_bases[qubit_index]
value but I keep getting "Oops 😕! Not the right bits.".
Am I using wrong gate or at the wrong time? Or is the problem somewhere else?
Hi roa7n, The bob_bases[qubit_index] value isn't an integer, so you must compare it with '0' or '1', is it your problem ?
Hi, may I ask where am I wrong? I get always the message "Oops 😕! Not the right bits."
bob_basis = bob_bases[qubit_index]
if bob_basis == 1:
qubit_circuit.h(0)
qubit_circuit.measure(0,0)
I know that it is too direct, but I think I misunderstood something
Hi, may I ask where am I wrong? I get always the message "Oops 😕! Not the right bits."
bob_basis = bob_bases[qubit_index] if bob_basis == 1: qubit_circuit.h(0) qubit_circuit.measure(0,0)
I know that it is too direct, but I think I misunderstood something
@amacaluso , as @Emixem pointed out, bob_basis is not an integer, its a string, it needs to be compared with "0" or "1". PS: You are already there.
Oh my goodness! I am very stupid :D It works ... Thanks!