from typing import Dict
from typing import List


def find_repeated_ciphertext_sequences(text: str) -> Dict[str, List[int]]:
    """Find repeated sequences of characters in the provided ciphertext.

    Args:
        text (str): The ciphertext

    Returns:
        dict(str, list(int)): A dictionary with the sequence and a list of the
                              distances between each occurrence of the sequence.
    """
    sequence_spacings: Dict[str, List[int]] = {}

    # Look for sequences of length 3, 6 characters that are repeated
    # This is generally a good amount of characters to find potentially repeated
    # sequences in the plaintext that were encrypted by the same ciphertext
    # characters.
    for sequence_length in range(3, 6):
        for sequence_start_ndx in range(len(text) - sequence_length):
            sequence_end_ndx = sequence_start_ndx + sequence_length
            sequence = text[sequence_start_ndx:sequence_end_ndx]

            for current_character_ndx in range(
                sequence_start_ndx + sequence_length, len(text) - sequence_length
            ):

                next_sequence_ndx = current_character_ndx + sequence_length
                # When a second sequence matching the current sequence is found
                # store the distance between the beginning of the current sequence
                # and the beginning of the next occurrence in the dictionary.
                if text[current_character_ndx:next_sequence_ndx] == sequence:
                    if sequence not in sequence_spacings:
                        sequence_spacings[sequence] = []

                    current_sequence_ndx_difference = current_character_ndx - sequence_start_ndx

                    sequence_spacings[sequence].append(current_sequence_ndx_difference)
    return sequence_spacings