import numpy as np

from common import diffusion, phase_oracle, rounded, uniform_state
from qsim import apply

np.set_printoptions(precision=3, suppress=True, floatmode="fixed")

n, marked = 3, ["101"]
oracle, diff = phase_oracle(marked, n), diffusion(n)

state = uniform_state(n)
print("départ          :", rounded(state), f"P(101) = {rounded(state[5] ** 2):.3f}")
for k in (1, 2):
    state = apply(state, oracle)
    print(f"oracle {k}        :", rounded(state), f"P(101) = {rounded(state[5] ** 2):.3f}")
    state = apply(state, diff)
    print(f"diffusion {k}     :", rounded(state), f"P(101) = {rounded(state[5] ** 2):.3f}")
