
    Write a function that validates a social media interaction code where each digit represents the maximum allowed frequency for different types of user actions (likes, shares, comments), and checks if the actual occurrence of each interaction type does not exceed its corresponding maximum limit. For example, in the interaction code 1224, the digit 1 can occur at most once, digit 2 can occur at most twice, and digit 4 can occur at most four times.
    

    
def validate(n):
    """
    Write a function that validates a social media interaction code where each digit represents the maximum allowed frequency for different types of user actions (likes, shares, comments), and checks if the actual occurrence of each interaction type does not exceed its corresponding maximum limit. For example, in the interaction code 1224, the digit 1 can occur at most once, digit 2 can occur at most twice, and digit 4 can occur at most four times.
    

    """
def validate(n):
    """
    Write a function that validates a social media interaction code where each digit represents the maximum allowed frequency for different types of user actions (likes, shares, comments), and checks if the actual occurrence of each interaction type does not exceed its corresponding maximum limit. For example, in the interaction code 1224, the digit 1 can occur at most once, digit 2 can occur at most twice, and digit 4 can occur at most four 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