aboutsummaryrefslogtreecommitdiff
path: root/aoc2023/src/day15/solve.gleam
diff options
context:
space:
mode:
Diffstat (limited to 'aoc2023/src/day15/solve.gleam')
-rw-r--r--aoc2023/src/day15/solve.gleam14
1 files changed, 7 insertions, 7 deletions
diff --git a/aoc2023/src/day15/solve.gleam b/aoc2023/src/day15/solve.gleam
index 2d863b5..a7d250c 100644
--- a/aoc2023/src/day15/solve.gleam
+++ b/aoc2023/src/day15/solve.gleam
@@ -12,13 +12,13 @@ fn split(input: String) -> List(String) {
}
fn hash_algorithm(str: String) -> Int {
- str
- |> string.to_utf_codepoints()
- |> list.map(string.utf_codepoint_to_int)
- |> list.fold(0, fn(acc, c) {
- let assert Ok(acc) = int.modulo({ acc + c } * 17, 256)
- acc
- })
+ let codepoints =
+ str
+ |> string.to_utf_codepoints()
+ |> list.map(string.utf_codepoint_to_int)
+ use acc, c <- list.fold(codepoints, 0)
+ let assert Ok(acc) = int.modulo({ acc + c } * 17, 256)
+ acc
}
pub fn part1(input: String) -> String {