def validator(targetFile):
    """
    Function to validate a password using a password policy.

    :param targetFile: path to input file.

    """

    inputFile = open(targetFile, 'r')
    lines = inputFile.readlines()

    targetCount = 0
    targetCountP2 = 0
    
    # policyNumbers = the numbers to be min and max
    # target = the letter to be counted
    # passwd = the password string to be checked

    for line in lines:
        splitPolicy = line.split(" ")
        policy = splitPolicy[0]
        policyNumbers = policy.split("-")
        target = splitPolicy[1].replace(':', '')
        passwd = splitPolicy[2]

        if int(policyNumbers[0]) <= passwd.count(target) <= int(policyNumbers[1]):
            targetCount += 1

        if (passwd[int(policyNumbers[0])-1] == str(target)) is not (passwd[int(policyNumbers[1])-1] == str(target)):
            targetCountP2 += 1
    
    inputFile.close()
    return targetCount, targetCountP2