From 8a4323bd169451f8559991dde0d004b03689d4c8 Mon Sep 17 00:00:00 2001 From: Caleb Webber Date: Tue, 3 Dec 2024 09:30:24 -0500 Subject: [PATCH] use case in day3 2024 --- elixir/livebook/2024/day3.livemd | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/elixir/livebook/2024/day3.livemd b/elixir/livebook/2024/day3.livemd index 8a2e79a..e0f0796 100644 --- a/elixir/livebook/2024/day3.livemd +++ b/elixir/livebook/2024/day3.livemd @@ -21,13 +21,12 @@ for instruction <- Regex.scan( input ), reduce: {true, 0} do {enabled?, acc} -> - (fn - false, ["mul" <> _ | _] -> {false, acc} - true, ["mul" <> _, _, a, b] -> {true, acc + String.to_integer(a) * String.to_integer(b)} - _, ["don" <> _ | _] -> {false, acc} - _, ["do()" | _] -> {true, acc} + case {enabled?, instruction} do + {false, ["mul" <> _ | _]} -> {false, acc} + {true, ["mul" <> _, _, a, b]} -> {true, acc + String.to_integer(a) * String.to_integer(b)} + {_, ["don" <> _ | _]} -> {false, acc} + {_, ["do()" | _]} -> {true, acc} end - ).(enabled?, instruction) end ```