Generate a de Bruijn sequence of a given length (and width). A de Bruijn
    sequence is a set of varying repetitions where each sequence of *n*
    characters is unique within the sequence. This type of sequence can be
    used to easily find the offset to the return pointer when exploiting a
    buffer overflow.

    Args:
        length(int): The length of the sequence to generate.
        width(int): The width of each element in the sequence.

    Returns:
        str: The sequence.

    Example:
        >>> from pwny import *
        >>> cycle(80)
        AAAABAAACAAADAAAEAAAFAAAGAAAHAAAIAAAJAAAKAAALAAAMAAANAAAOAAAPAAAQAAARAAASAAATAAA

def cycle(length, width=4):
    """
    Generate a de Bruijn sequence of a given length (and width). A de Bruijn
    sequence is a set of varying repetitions where each sequence of *n*
    characters is unique within the sequence. This type of sequence can be
    used to easily find the offset to the return pointer when exploiting a
    buffer overflow.

    Args:
        length(int): The length of the sequence to generate.
        width(int): The width of each element in the sequence.

    Returns:
        str: The sequence.

    Example:
        >>> from pwny import *
        >>> cycle(80)
        AAAABAAACAAADAAAEAAAFAAAGAAAHAAAIAAAJAAAKAAALAAAMAAANAAAOAAAPAAAQAAARAAASAAATAAA
    """

    iter = deBruijn(width, 26)
    return ''.join([chr(ord('A') + next(iter)) for i in range(length)])