def build_oracle(n: int, f) -> QuantumCircuit:
    controls = QuantumRegister(n, 'ofc')
    oracle = QuantumCircuit(controls, name='Zf')
    for i in range((2 ** n)):
        rep = np.binary_repr(i, n)
        if (f(rep) == '1'):
            for j in range(n):
                if (rep[j] == '0'):
                    oracle.x(controls[j])
            if (n >= 2):
                oracle.mcu1(pi, controls[1:], controls[0])
            for j in range(n):
                if (rep[j] == '0'):
                    oracle.x(controls[j])
    return oracle
def build_oracle(n: int, f) -> QuantumCircuit:
    controls = QuantumRegister(n, 'ofc')
    oracle = QuantumCircuit(controls, name='Zf')
    for i in range((2 ** n)):
        rep = np.binary_repr(i, n)
        if (f(rep) == '1'):
            for j in range(n):
                if (rep[j] == '0'):
                    oracle.x(controls[j])
            if (n >= 2):
                oracle.mcu1(pi, controls[1:], controls[0])
            for j in range(n):
                if (rep[j] == '0'):
                    oracle.x(controls[j])
    return oracle