Advertisement
Guest User

CatboxScissors

a guest
Jan 25th, 2018
280
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. include "qelib1.inc";
  2. qreg q[5];
  3. creg c[5];
  4.  
  5. // prepare the referee qubit q[2] as a |+> state
  6. h q[2];
  7.  
  8. /////////////// INPUT HERE ///////////////
  9. // Make your move by choosing s or sdg
  10. // Comment the one you don't want
  11.  
  12. s q[2];
  13. //sdg q[2];
  14.  
  15. /////////////////////////////////////////
  16.  
  17. // next a quantum opponent also chooses a move
  18. // then a referee compares your choices
  19. // if you chose the same, the opponent wins
  20. // if you chose different, you win
  21.  
  22.  
  23.  
  24. // the quantum player q[0] makes its move
  25. h q[0]; // hadamard to make it random
  26. s q[2]; // apply an s to the referee
  27. // then use a controlled-Z to turn this into sdq if q[0] is |1>
  28. h q[2];
  29. cx q[0],q[2];
  30. h q[2];
  31.  
  32. // referee is now in |+> state if you lose and |-> if you win, so measure
  33. h q[2];
  34. measure q[2] -> c[4];
  35.  
  36. // the result 10000 means you win
  37. // the result 00000 means you lose
  38.  
  39. // to play against a different qubit, replace all instances of q[0] above with
  40. // q[1], q[3] or q[4]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement