<s> """<STR_LIT>""" <EOL> from sympy import pprint <EOL> from sympy . physics . quantum import qapply <EOL> from sympy . physics . quantum . qubit import IntQubit <EOL> from sympy . physics . quantum . grover import ( OracleGate , superposition_basis , <EOL> WGate , grover_iteration ) <EOL> def demo_vgate_app ( v ) : <EOL> for i in range ( <NUM_LIT:2> ** v . nqubits ) : <EOL> print ( '<STR_LIT>' % ( i , v . nqubits ) ) <EOL> pprint ( qapply ( v * IntQubit ( i , v . nqubits ) ) ) <EOL> qapply ( v * IntQubit ( i , v . nqubits ) ) <EOL> def black_box ( qubits ) : <EOL> return True if qubits == IntQubit ( <NUM_LIT:1> , qubits . nqubits ) else False <EOL> def main ( ) : <EOL> print ( ) <EOL> print ( '<STR_LIT>' ) <EOL> print ( '<STR_LIT>' ) <EOL> print ( '<STR_LIT>' ) <EOL> print ( '<STR_LIT>' ) <EOL> print ( ) <EOL> nqubits = <NUM_LIT:2> <EOL> print ( '<STR_LIT>' , nqubits ) <EOL> v = OracleGate ( nqubits , black_box ) <EOL> print ( '<STR_LIT>' % nqubits ) <EOL> print ( ) <EOL> psi = superposition_basis ( nqubits ) <EOL> print ( '<STR_LIT>' ) <EOL> pprint ( psi ) <EOL> demo_vgate_app ( v ) <EOL> print ( '<STR_LIT>' ) <EOL> pprint ( qapply ( v * psi ) ) <EOL> print ( ) <EOL> w = WGate ( nqubits ) <EOL> print ( '<STR_LIT>' % nqubits ) <EOL> print ( '<STR_LIT>' ) <EOL> print ( '<STR_LIT>' ) <EOL> pprint ( qapply ( w * v * psi ) ) <EOL> print ( ) <EOL> nqubits = <NUM_LIT:3> <EOL> print ( '<STR_LIT>' ) <EOL> print ( '<STR_LIT>' ) <EOL> psi = superposition_basis ( nqubits ) <EOL> print ( '<STR_LIT>' ) <EOL> pprint ( psi ) <EOL> v = OracleGate ( nqubits , black_box ) <EOL> print ( '<STR_LIT>' % nqubits ) <EOL> print ( ) <EOL> print ( '<STR_LIT>' ) <EOL> iter1 = qapply ( grover_iteration ( psi , v ) ) <EOL> pprint ( iter1 ) <EOL> print ( ) <EOL> print ( '<STR_LIT>' ) <EOL> iter2 = qapply ( grover_iteration ( iter1 , v ) ) <EOL> pprint ( iter2 ) <EOL> print ( ) <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> main ( ) </s>
