import numpy as np

from common import grover, rounded, success

n, marked = 4, ["0110"]
theta = np.arcsin(1 / np.sqrt(2**n))
k = int(np.floor(np.pi / (4 * theta)))
print("θ =", rounded(theta, 4), "rad ; itérations conseillées :", k)
for iterations in range(1, k + 2):
    print(f"{iterations} itération(s) : P = {rounded(success(grover(marked, n, iterations), marked, n)):.3f}")
