diff --git a/src/day2_p2.gleam b/src/day2_p2.gleam index 718dc00..ca325f8 100644 --- a/src/day2_p2.gleam +++ b/src/day2_p2.gleam @@ -12,23 +12,19 @@ pub fn main() { |> io.debug } +fn is_safe_all_combo(list: List(Int)) -> Bool { + range(0, length(list) - 1) + |> any(fn(index) { + let assert #(before, [_, ..after]) = list |> split(index) + flatten([before, after]) |> is_safe + }) +} + type Direction { Increasing Decreasing } -fn is_safe_all_combo(list: List(Int)) -> Bool { - case is_safe(list) { - True -> True - False -> - range(0, length(list) - 1) - |> any(fn(index) { - let assert #(before, [_, ..after]) = list |> split(index) - flatten([before, after]) |> is_safe - }) - } -} - fn is_safe(list: List(Int)) -> Bool { // Evaluate direction, then call the actual checking function case list {