Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- include "qelib1.inc";
- qreg q[5];
- creg c[5];
- // prepare the referee qubit q[2] as a |+> state
- h q[2];
- /////////////// INPUT HERE ///////////////
- // Make your move by choosing s or sdg
- // Comment the one you don't want
- s q[2];
- //sdg q[2];
- /////////////////////////////////////////
- // next a quantum opponent also chooses a move
- // then a referee compares your choices
- // if you chose the same, the opponent wins
- // if you chose different, you win
- // the quantum player q[0] makes its move
- h q[0]; // hadamard to make it random
- s q[2]; // apply an s to the referee
- // then use a controlled-Z to turn this into sdq if q[0] is |1>
- h q[2];
- cx q[0],q[2];
- h q[2];
- // referee is now in |+> state if you lose and |-> if you win, so measure
- h q[2];
- measure q[2] -> c[4];
- // the result 10000 means you win
- // the result 00000 means you lose
- // to play against a different qubit, replace all instances of q[0] above with
- // q[1], q[3] or q[4]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement