From e1171830b99a0f542be311b227b21cd06f540d77 Mon Sep 17 00:00:00 2001 From: trwnh Date: Wed, 2 Dec 2020 11:00:12 -0600 Subject: [PATCH] shorter xor --- 02/02.exs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/02/02.exs b/02/02.exs index e75604a..6841374 100644 --- a/02/02.exs +++ b/02/02.exs @@ -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()