From f9db17b2e3bc9ee9243499ae4bce327245bb9ef7 Mon Sep 17 00:00:00 2001 From: Wesley Moore Date: Thu, 1 Dec 2022 17:10:26 +1000 Subject: [PATCH] Day 1 part 2 --- 2022/src/days/day_1.gleam | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/2022/src/days/day_1.gleam b/2022/src/days/day_1.gleam index 1d45ccf..7bc89c2 100644 --- a/2022/src/days/day_1.gleam +++ b/2022/src/days/day_1.gleam @@ -1,7 +1,6 @@ import gleam/string import gleam/int import gleam/list -import gleam/io pub fn pt_1(input: String) -> Int { assert Ok(max) = @@ -12,7 +11,12 @@ pub fn pt_1(input: String) -> Int { } pub fn pt_2(input: String) -> Int { - todo + string.split(input, on: "\n") + |> aggregate_calories([0]) + |> list.sort(int.compare) + |> list.reverse + |> list.take(3) + |> int.sum } fn aggregate_calories(lines: List(String), sums: List(Int)) -> List(Int) {