
    Write a function that validates an event group's interest distribution code, where each digit represents a different interest category (1-9), and the frequency of participants sharing each interest type must not exceed the category number itself to maintain group diversity. For example, in code 11223, music interests (1) appear twice which is invalid since category 1 should not have more than one participant, while sports interests (2) appear twice which is valid since category 2 can have up to two participants.
    

    
def validate(n):
    """
    Write a function that validates an event group's interest distribution code, where each digit represents a different interest category (1-9), and the frequency of participants sharing each interest type must not exceed the category number itself to maintain group diversity. For example, in code 11223, music interests (1) appear twice which is invalid since category 1 should not have more than one participant, while sports interests (2) appear twice which is valid since category 2 can have up to two participants.
    

    """
def validate(n):
    """
    Write a function that validates an event group's interest distribution code, where each digit represents a different interest category (1-9), and the frequency of participants sharing each interest type must not exceed the category number itself to maintain group diversity. For example, in code 11223, music interests (1) appear twice which is invalid since category 1 should not have more than one participant, while sports interests (2) appear twice which is valid since category 2 can have up to two participants.
    

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