simplify
This commit is contained in:
parent
68f61fb9e1
commit
eea7beb6e3
1 changed files with 8 additions and 12 deletions
|
@ -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 {
|
||||
|
|
Loading…
Reference in a new issue