import numpy as np

from qsim.etape3_plusieurs_qubits import ZERO, apply_cnot, kron, make_state

np.set_printoptions(precision=3, suppress=True)

# Exercice 2 : trois CNOT alternés échangent deux qubits
psi = make_state(0.6, 0.8)
state = kron(psi, ZERO)
print("avant :", state)

state = apply_cnot(state, 0, 1)
state = apply_cnot(state, 1, 0)
state = apply_cnot(state, 0, 1)
print("après :", state)
print("égal à kron(ZERO, psi) :", np.allclose(state, kron(ZERO, psi)))
