this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

:recycle: refactor code

+4 -8
+4 -7
src/day_01.gleam
··· 38 38 [] -> acc 39 39 [command, ..rest] -> { 40 40 let assert Ok(new_value) = case command { 41 - Command(operation: "L", value: v) -> { 41 + Command(operation: "R", value: v) -> position + v 42 + Command(operation: _, value: v) -> { 42 43 let calc = position - v 43 44 44 - use <- bool.guard(when: calc < 0, return: int.modulo(100 + calc, 100)) 45 + use <- bool.guard(when: calc < 0, return: 100 + calc) 45 46 46 47 calc 47 - |> int.modulo(100) 48 - } 49 - Command(operation: _, value: v) -> { 50 - position + v 51 - |> int.modulo(100) 52 48 } 53 49 } 50 + |> int.modulo(100) 54 51 55 52 let new_acc = case new_value { 56 53 0 -> acc + 1
-1
test/day_01_test.gleam
··· 30 30 31 31 assert file 32 32 |> day_01.format_input 33 - |> echo 34 33 |> day_01.calculate_distances 35 34 == 1105 36 35 }