
    Write a function that validates a transaction security code where each digit represents the maximum allowed validations for a specific security checkpoint level, and the function must verify that the actual number of occurrences of each digit (representing validation attempts) does not exceed its own value. For example, in code "1122", the digit 1 appears twice which is invalid since 1 can only appear once, while 2 appears twice which is valid since 2 can appear up to two times.
    

    
def validate(n):
    """
    Write a function that validates a transaction security code where each digit represents the maximum allowed validations for a specific security checkpoint level, and the function must verify that the actual number of occurrences of each digit (representing validation attempts) does not exceed its own value. For example, in code "1122", the digit 1 appears twice which is invalid since 1 can only appear once, while 2 appears twice which is valid since 2 can appear up to two times.
    

    """
def validate(n):
    """
    Write a function that validates a transaction security code where each digit represents the maximum allowed validations for a specific security checkpoint level, and the function must verify that the actual number of occurrences of each digit (representing validation attempts) does not exceed its own value. For example, in code "1122", the digit 1 appears twice which is invalid since 1 can only appear once, while 2 appears twice which is valid since 2 can appear up to two 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