This commit is contained in:
Hamcha 2024-12-03 22:16:33 +01:00
parent 68f61fb9e1
commit eea7beb6e3
Signed by: hamcha
GPG key ID: 1669C533B8CF6D89

View file

@ -12,21 +12,17 @@ pub fn main() {
|> io.debug |> io.debug
} }
type Direction {
Increasing
Decreasing
}
fn is_safe_all_combo(list: List(Int)) -> Bool { fn is_safe_all_combo(list: List(Int)) -> Bool {
case is_safe(list) {
True -> True
False ->
range(0, length(list) - 1) range(0, length(list) - 1)
|> any(fn(index) { |> any(fn(index) {
let assert #(before, [_, ..after]) = list |> split(index) let assert #(before, [_, ..after]) = list |> split(index)
flatten([before, after]) |> is_safe flatten([before, after]) |> is_safe
}) })
} }
type Direction {
Increasing
Decreasing
} }
fn is_safe(list: List(Int)) -> Bool { fn is_safe(list: List(Int)) -> Bool {