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,23 +12,19 @@ pub fn main() {
|> io.debug |> 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 { type Direction {
Increasing Increasing
Decreasing 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 { fn is_safe(list: List(Int)) -> Bool {
// Evaluate direction, then call the actual checking function // Evaluate direction, then call the actual checking function
case list { case list {