Codercise S.3.1 potential mistake

Hi. In Codercise S.3.1, the print output for the circuit matrix does not match the one in the get_phase function


I suppose it is possible to print the binary in the function instead
e.g.

Hi @cyyoung ,

Can you please clarify what you mean?

Both solutions seem to be equivalent.

Could you maybe add an example?

If your code isn’t passing the tests it’s because of what you have in your circuit, not something wrong in the get_phase function.

The For loop is printing a random sample that is different from the random sample in get_phase().
Here’s an example:


The binary values printed don’t match the phase because it is not the same sample that was called.
The edited code passes the test and prints the right fractional binary

Hi, thanks for catching this.
Yeah, you are definitely right about this bug.
I will implement your suggestion so we print the corresponding values.

Have a nice day!

1 Like