aboutsummaryrefslogtreecommitdiff
path: root/aoc2023
diff options
context:
space:
mode:
Diffstat (limited to 'aoc2023')
-rw-r--r--aoc2023/src/day22/solve.gleam9
-rw-r--r--aoc2023/test/day22/day22_test.gleam8
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,
),
]