diff options
author | J.J <thechairman@thechairman.info> | 2023-12-22 22:51:52 -0500 |
---|---|---|
committer | J.J <thechairman@thechairman.info> | 2023-12-22 22:51:52 -0500 |
commit | 3c5144c6120e27c2013dc95ae8aeebd84103296e (patch) | |
tree | 719f4a646d94f32e3535d3a64161b909078b2e7d | |
parent | d739c6223d29de72a2d1fab4ac9fb34603414f6b (diff) | |
download | gleam_aoc-3c5144c6120e27c2013dc95ae8aeebd84103296e.tar.gz gleam_aoc-3c5144c6120e27c2013dc95ae8aeebd84103296e.zip |
day 22 gleam complete
-rw-r--r-- | aoc2023/src/day22/solve.gleam | 9 | ||||
-rw-r--r-- | aoc2023/test/day22/day22_test.gleam | 8 |
2 files changed, 7 insertions, 10 deletions
diff --git a/aoc2023/src/day22/solve.gleam b/aoc2023/src/day22/solve.gleam index b1c360f..7bf2fb4 100644 --- a/aoc2023/src/day22/solve.gleam +++ b/aoc2023/src/day22/solve.gleam @@ -134,9 +134,7 @@ pub fn part1(input: String) { let vulnerable_blocks = vulnerable_blocks(below_blocks) - list.length(dict.keys(block_positions)) - - list.length(vulnerable_blocks) - |> string.inspect + list.length(dict.keys(block_positions)) - list.length(vulnerable_blocks) } fn all_falling_blocks(n: Int, above: BlockTree, below: BlockTree) { @@ -181,9 +179,8 @@ pub fn part2(input: String) { let vulnerable_blocks = vulnerable_blocks(below_blocks) - list.map(vulnerable_blocks, all_falling_blocks(_, above_blocks, below_blocks)) - |> int.sum - |> string.inspect + use acc, b <- list.fold(vulnerable_blocks, 0) + acc + all_falling_blocks(b, above_blocks, below_blocks) } pub fn main() { diff --git a/aoc2023/test/day22/day22_test.gleam b/aoc2023/test/day22/day22_test.gleam index 1760ece..3f8c0ca 100644 --- a/aoc2023/test/day22/day22_test.gleam +++ b/aoc2023/test/day22/day22_test.gleam @@ -4,10 +4,10 @@ import adglent.{type Example, Example} import day22/solve type Problem1AnswerType = - String + Int type Problem2AnswerType = - String + Int /// Add examples for part 1 here: /// ```gleam @@ -22,7 +22,7 @@ const part1_examples: List(Example(Problem1AnswerType)) = [ 2,0,5~2,2,5 0,1,6~2,1,6 1,1,8~1,1,9", - "5", + 5, ), ] @@ -39,7 +39,7 @@ const part2_examples: List(Example(Problem2AnswerType)) = [ 2,0,5~2,2,5 0,1,6~2,1,6 1,1,8~1,1,9", - "7", + 7, ), ] |