shorter xor

This commit is contained in:
a 2020-12-02 11:00:12 -06:00
parent aa78a1b463
commit e1171830b9

View file

@ -31,7 +31,7 @@ list
fn {p1, p2, character, password} ->
first = Enum.at(password, p1-1) == character
second = Enum.at(password, p2-1) == character
(first and !second) or (!first and second)
first != second # exclusive or is equivalent to two things not matching (not both true or both false)
end
)
|> Enum.count()