def find_subcircuit(circuit, subcircuit, start=0, end=0):

    if isinstance(circuit, Mul):
        circuit = circuit.args

    if isinstance(subcircuit, Mul):
        subcircuit = subcircuit.args

    if len(subcircuit) == 0 or len(subcircuit) > len(circuit):
        return -1

    if end < 1:
        end = len(circuit)

    # Location in circuit
    pos = start
    # Location in the subcircuit
    index = 0
    # 'Partial match' table
    table = kmp_table(subcircuit)

    while (pos + index) < end:
        if subcircuit[index] == circuit[pos + index]:
            index = index + 1
        else:
            pos = pos + index - table[index]
            index = table[index] if table[index] > -1 else 0

        if index == len(subcircuit):
            return pos

    return -1
Grabs user input from command line from set of provided choices.
dataset/ETHPy150Open sympy/sympy/sympy/physics/quantum/circuitutils.py/find_subcircuit--crossover with--dataset/ETHPy150Open danjac/Flask-Script/flaskext/script.py/prompt_choices