
    Write a function that validates a bus route identifier where each digit represents the maximum passenger capacity for different route segments, and verify that the number of times each digit appears in the route number doesn't exceed that digit's value. For example, in route 432, the digit 4 can appear up to 4 times, 3 can appear up to 3 times, and 2 can appear up to 2 times.
    

    
def validate(n):
    """
    Write a function that validates a bus route identifier where each digit represents the maximum passenger capacity for different route segments, and verify that the number of times each digit appears in the route number doesn't exceed that digit's value. For example, in route 432, the digit 4 can appear up to 4 times, 3 can appear up to 3 times, and 2 can appear up to 2 times.
    

    """
def validate(n):
    """
    Write a function that validates a bus route identifier where each digit represents the maximum passenger capacity for different route segments, and verify that the number of times each digit appears in the route number doesn't exceed that digit's value. For example, in route 432, the digit 4 can appear up to 4 times, 3 can appear up to 3 times, and 2 can appear up to 2 times.
    

    """
    for i in range(10):
        temp = n
        count = 0
        while temp:
            if temp % 10 == i:
                count += 1
            if count > i:
                return False
            temp //= 10
    return True