my solutions to advent of code
aoc advent-of-code

nicer looking

aylac.top 4338d874 4b34c3f0

verified
Changed files
+12 -17
2025
1
gleam
+12 -17
2025/1/gleam/src/main.gleam
···
import gleam/int
import gleam/io
import gleam/list
import gleam/string
import simplifile as file
···
|> string.trim
|> string.split("\n")
|> list.map(fn(l) {
-
let assert Ok(direction_letter) = string.first(l)
-
let direction = case direction_letter {
-
"R" -> Right
-
"L" -> Left
_ -> panic as "bad input"
}
-
let assert Ok(turn) = string.drop_start(l, 1) |> int.parse
-
InputEntry(direction, turn)
})
let part1 =
input
|> list.fold(RotationState(50, 0), fn(acc, v) {
let new_number =
-
{
acc.number
-
+ case v.direction {
Right -> v.turn
Left -> -v.turn
-
}
-
}
-
% 100
RotationState(
new_number,
acc.zeroes
···
Left -> -v.turn
}
// took too long to remember that abs isn't this im so fucking stupid
-
let new_number = raw_new_number % 100
-
// this seems to be useless here but i might be a genius who put it preventively
-
let new_number = case new_number > 0 {
-
True -> new_number
-
False -> 100 + new_number
-
}
// dumbest fuck in the world??? theres gotta be a mathy way of doing this
let times_it_went_zero =
list.range(acc.number, raw_new_number)
···
import gleam/int
import gleam/io
import gleam/list
+
import gleam/result
import gleam/string
import simplifile as file
···
|> string.trim
|> string.split("\n")
|> list.map(fn(l) {
+
let #(direction, turn) = case l {
+
"R" <> turn -> #(Right, turn)
+
"L" <> turn -> #(Left, turn)
_ -> panic as "bad input"
}
+
InputEntry(direction, turn |> int.parse |> result.unwrap(0))
})
let part1 =
input
|> list.fold(RotationState(50, 0), fn(acc, v) {
let new_number =
+
int.modulo(
acc.number
+
+ case v.direction {
Right -> v.turn
Left -> -v.turn
+
},
+
100,
+
)
+
|> result.unwrap(0)
RotationState(
new_number,
acc.zeroes
···
Left -> -v.turn
}
// took too long to remember that abs isn't this im so fucking stupid
+
let new_number = int.modulo(raw_new_number, 100) |> result.unwrap(0)
// dumbest fuck in the world??? theres gotta be a mathy way of doing this
let times_it_went_zero =
list.range(acc.number, raw_new_number)