shorter xor
This commit is contained in:
parent
aa78a1b463
commit
e1171830b9
|
@ -31,7 +31,7 @@ list
|
||||||
fn {p1, p2, character, password} ->
|
fn {p1, p2, character, password} ->
|
||||||
first = Enum.at(password, p1-1) == character
|
first = Enum.at(password, p1-1) == character
|
||||||
second = Enum.at(password, p2-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
|
end
|
||||||
)
|
)
|
||||||
|> Enum.count()
|
|> Enum.count()
|
||||||
|
|
Loading…
Reference in a new issue