
    Write a function that validates an event's social engagement ID number, where each digit represents a different engagement metric (shares, likes, comments), by ensuring that the frequency of each digit's occurrence in the ID is not greater than the value of the digit itself. For example, in an engagement ID, the digit 3 should not appear more than 3 times, the digit 2 should not appear more than 2 times, and so on, to maintain balanced social interaction patterns.
    

    
def validate(n):
    """
    Write a function that validates an event's social engagement ID number, where each digit represents a different engagement metric (shares, likes, comments), by ensuring that the frequency of each digit's occurrence in the ID is not greater than the value of the digit itself. For example, in an engagement ID, the digit 3 should not appear more than 3 times, the digit 2 should not appear more than 2 times, and so on, to maintain balanced social interaction patterns.
    

    """
def validate(n):
    """
    Write a function that validates an event's social engagement ID number, where each digit represents a different engagement metric (shares, likes, comments), by ensuring that the frequency of each digit's occurrence in the ID is not greater than the value of the digit itself. For example, in an engagement ID, the digit 3 should not appear more than 3 times, the digit 2 should not appear more than 2 times, and so on, to maintain balanced social interaction patterns.
    

    """
    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