
    Write a function that validates a patient's composite health severity score by ensuring that the occurrence count of each severity level (0-9) in the score does not exceed the severity level itself, where each digit represents the severity of different vital parameters measured in the ICU. For example, in a score of 3221, severity level 2 appears twice which is valid since 2>=2, and in a score of 3331, severity level 3 appears three times which is valid since 3>=3.
    

    
def validate(n):
    """
    Write a function that validates a patient's composite health severity score by ensuring that the occurrence count of each severity level (0-9) in the score does not exceed the severity level itself, where each digit represents the severity of different vital parameters measured in the ICU. For example, in a score of 3221, severity level 2 appears twice which is valid since 2>=2, and in a score of 3331, severity level 3 appears three times which is valid since 3>=3.
    

    """
def validate(n):
    """
    Write a function that validates a patient's composite health severity score by ensuring that the occurrence count of each severity level (0-9) in the score does not exceed the severity level itself, where each digit represents the severity of different vital parameters measured in the ICU. For example, in a score of 3221, severity level 2 appears twice which is valid since 2>=2, and in a score of 3331, severity level 3 appears three times which is valid since 3>=3.
    

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