import random


def generate_random_pattern(length: int = -1) -> str:
    """
    Generates a random license plate pattern. If length is provided,
    the generated pattern will have the length passed, else, its
    length will be a random number between 4 and 8.
    """
    MIN, MAX = 4, 8  # Min and Max lengths if len is not provided
    if length < 0:
        length = random.randint(MIN, MAX)

    pattern: str = "".join(
        ["C" if random.randint(0, 1) else "D" for _ in range(length)]
    )
    return pattern