def decode(encoded_digits: list[str], mapping: dict) -> int:
    """decode a number.

    Use the mapping to decode the encoded digits and combine them to a number.

    Args:
        encoded_digits (list[str]): encoded digits
        mapping (dict): mapping that decodes each segment

    Returns:
        (int) decoded number

    Examples:
        >>> decode(["cf", "fc", "acf"], {"a":"a", "c":"c", "f":"f"})
        117
        >>> decode(["cb", "bc", "acb"], {"a":"a", "c":"c", "b":"f"})
        117
        >>> decode(["fcdb", "bc", "acb"], {"a":"a", "b":"f", "c":"c", "d":"d", "f":"b"})
        417
    """
    digits = {
        "abcefg": "0",
        "cf": "1",
        "acdeg": "2",
        "acdfg": "3",
        "bcdf": "4",
        "abdfg": "5",
        "abdefg": "6",
        "acf": "7",
        "abcdefg": "8",
        "abcdfg": "9",
    }
    result = ""
    for digit in encoded_digits:
        decoded_segments = ""
        for segment in digit:
            decoded_segments += mapping[segment]
        decoded_segments = "".join(sorted(decoded_segments))
        result += digits[decoded_segments]
    return int(result)