aboutsummaryrefslogtreecommitdiff
path: root/aoc2019_gleam/src/aoc_2019/day_1.gleam
diff options
context:
space:
mode:
authorH.J <thechairman@thechairman.info>2024-06-03 10:36:31 -0400
committerH.J <thechairman@thechairman.info>2024-06-03 10:36:31 -0400
commit7d704786ec158349f2f34590a858df6e78e844d6 (patch)
tree2a5b0f0af3bc2c322e941d25e2da9f9e66a6cdd3 /aoc2019_gleam/src/aoc_2019/day_1.gleam
parent9f0484222417d6b1495636123ae7de278b9fd0e5 (diff)
downloadgleam_aoc-7d704786ec158349f2f34590a858df6e78e844d6.tar.gz
gleam_aoc-7d704786ec158349f2f34590a858df6e78e844d6.zip
gleam day 1 2017
Diffstat (limited to 'aoc2019_gleam/src/aoc_2019/day_1.gleam')
-rw-r--r--aoc2019_gleam/src/aoc_2019/day_1.gleam30
1 files changed, 0 insertions, 30 deletions
diff --git a/aoc2019_gleam/src/aoc_2019/day_1.gleam b/aoc2019_gleam/src/aoc_2019/day_1.gleam
deleted file mode 100644
index 8a7fd2d..0000000
--- a/aoc2019_gleam/src/aoc_2019/day_1.gleam
+++ /dev/null
@@ -1,30 +0,0 @@
-import gleam/int
-import gleam/list
-import gleam/result
-import gleam/string
-
-pub fn parse(input: String) -> List(Int) {
- input
- |> string.split("\n")
- |> list.map(int.parse)
- |> result.values()
-}
-
-pub fn pt_1(input: List(Int)) {
- list.fold(input, 0, fn(total, next) { total + naive_fuel(next) })
-}
-
-pub fn pt_2(input: List(Int)) {
- list.fold(input, 0, fn(total, next) { total + recursive_fuel(next) })
-}
-
-fn naive_fuel(weight: Int) -> Int {
- { weight / 3 } - 2
-}
-
-fn recursive_fuel(weight: Int) -> Int {
- case { weight / 3 } - 2 {
- n if n <= 0 -> 0
- n -> n + recursive_fuel(n)
- }
-}