import re
import operator


def is_valid(policy: str, password: str) -> bool:
    """
    Given a policy (e.g. `1-3 a`) and a password (e.g. `abcde`),
    determine if the password complies with the policy
    """
    char = policy[-1:]
    pos_1 = int(re.findall("[0-9]+", policy)[0])
    pos_2 = int(re.findall("[0-9]+", policy)[1])

    return operator.xor((password[pos_1 - 1] == char), (password[pos_2 - 1] == char))