def extract_number_and_preamble(index, sequence, preamble_length=25):
    """
    Extracts the number given by the sequence, as well as the preamble.

    >>> extract_number_and_preamble(25, list(range(1,26))+[46])
    (46, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25])

    >>> extract_number_and_preamble(5, list(range(1,26))+[46], preamble_length=5)
    (6, [1, 2, 3, 4, 5])

    :param index:
    :param sequence:
    :param preamble_length:
    :return:
    """
    number = sequence[index]
    start = max(0, index-preamble_length)
    preamble = sequence[start:start+preamble_length]
    return number, preamble