diff --git a/src/aoc_2024/day_5.gleam b/src/aoc_2024/day_5.gleam index 0bd794a..ef76358 100644 --- a/src/aoc_2024/day_5.gleam +++ b/src/aoc_2024/day_5.gleam @@ -98,7 +98,7 @@ fn fix_order_rec(todos: List(#(Int, Set(Int))), acc: List(Int)) -> List(Int) { True -> acc False -> { let #(usable, rest) = - extra.list_partition(todos, fn(todo_) { set.is_empty(todo_.1) }) + list.partition(todos, fn(todo_) { set.is_empty(todo_.1) }) let usable_pages: List(Int) = usable |> list.map(fn(todo_) { todo_.0 }) let cleaned_rest: List(#(Int, Set(Int))) = rest diff --git a/src/extra.gleam b/src/extra.gleam index b4d7e42..1888ab1 100644 --- a/src/extra.gleam +++ b/src/extra.gleam @@ -63,15 +63,3 @@ pub fn strip_left(from input: String, remove prefix: String) -> String { False -> input } } - -/// Splits list into a #(good, bad) based on a predicate (true, false) -pub fn list_partition(xs: List(a), pred: fn(a) -> Bool) -> #(List(a), List(a)) { - let #(good_rev, bad_rev) = - list.fold(xs, #([], []), fn(acc, x) { - case pred(x) { - True -> #([x, ..acc.0], acc.1) - False -> #(acc.0, [x, ..acc.1]) - } - }) - #(list.reverse(good_rev), list.reverse(bad_rev)) -}