from typing import Optional
from typing import List
import random


def generate_random_number(
    length: int = 6, forbidden_first_digit: Optional[List[int]] = None
) -> str:
    """
    Generate random number with the provided length (number of digits) ensuring that two neighboring
    digits are always different and with each digit having a value between 1 - 9.
    """
    result = ""

    while len(result) < length:
        random_value = random.randint(0, 9)

        if len(result) == 0:
            # First digit
            if forbidden_first_digit and random_value in forbidden_first_digit:
                continue

            result += str(random_value)
        else:
            # Make sure it's different than the previous digit
            if random_value == int(result[-1]):
                continue

            result += str(random_value)

    return result