may4_challenge_exercises icon indicating copy to clipboard operation
may4_challenge_exercises copied to clipboard

I am very confused whatever gate should use here.

Open vstar999 opened this issue 4 years ago • 7 comments

def bob_measure_qubit(bob_bases, qubit_index, qubit_circuit): # # # insert your code here to measure Alice's bits

vstar999 avatar May 05 '20 11:05 vstar999

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.

Emixem avatar May 05 '20 13:05 Emixem

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.

Gopal-Dahale avatar May 07 '20 04:05 Gopal-Dahale

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?

roa7n avatar May 07 '20 14:05 roa7n

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 ?

Emixem avatar May 07 '20 14:05 Emixem

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 avatar May 07 '20 15:05 amacaluso

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.

abhik-99 avatar May 07 '20 18:05 abhik-99

Oh my goodness! I am very stupid :D It works ... Thanks!

amacaluso avatar May 07 '20 18:05 amacaluso