import numpy as np

from common import dot, simon_circuit, simon_function
from qsim import sample

n, secret = 3, 0b110
f = simon_function(secret, n, np.random.default_rng(42))
state = simon_circuit(f, n)

# 1 000 exécutions ; on ne garde que le registre d'entrée (les 3 premiers bits)
counts = {}
for key, c in sample(state, 1000, seed=42).items():
    counts[key[:n]] = counts.get(key[:n], 0) + c
for z, c in counts.items():
    print(f"z = {z} : {c:>3} fois, z · s = {dot(int(z, 2), secret)}")
