Given an element of a de Bruijn sequence, find its index in that sequence.

    Args:
        key(str): The piece of the de Bruijn sequence to find.
        width(int): The width of each element in the sequence.

    Returns:
        int: The index of ``key`` in the de Bruijn sequence.

def cycle_find(key, width=4):
    """
    Given an element of a de Bruijn sequence, find its index in that sequence.

    Args:
        key(str): The piece of the de Bruijn sequence to find.
        width(int): The width of each element in the sequence.

    Returns:
        int: The index of ``key`` in the de Bruijn sequence.
    """

    key_len = len(key)
    buf = ''

    it = deBruijn(width, 26)

    for i in range(key_len):
        buf += chr(ord('A') + next(it))

    if buf == key:
        return 0

    for i, c in enumerate(it):
        buf = buf[1:] + chr(ord('A') + c)
        if buf == key:
            return i + 1

    return -1