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

updated consistency

aylac.top ef60f2b2 3042768f

verified
Changed files
+7 -5
2025
1
gleam
rust
src
+5 -5
2025/1/gleam/src/main.gleam
···
import simplifile as file
pub type RotationState {
-
RotationState(number: Int, zeroes: Int)
}
pub fn main() {
···
input
|> list.fold(RotationState(50, 0), fn(acc, v) {
let new_number =
-
int.modulo(acc.number + v, 100)
|> result.unwrap(0)
RotationState(new_number, case new_number {
0 -> acc.zeroes + 1
···
let part2 =
input
|> list.fold(RotationState(50, 0), fn(acc, v) {
-
let raw_new_number = acc.number + v
let raw_zeroes = int.absolute_value(raw_new_number / 100)
let zeroes =
acc.zeroes
-
+ case acc.number != 0 && raw_new_number <= 0 {
// if it is below zero before being moduloed and the original number itself wasn't zero it means that it did touch zero but the division thing wouldn't count it, so we give this extra support.
-
// of course, there is no need to deal with a negative to positive situation because the acc number will never be negative!!!
True -> raw_zeroes + 1
False -> raw_zeroes
}
···
import simplifile as file
pub type RotationState {
+
RotationState(turn: Int, zeroes: Int)
}
pub fn main() {
···
input
|> list.fold(RotationState(50, 0), fn(acc, v) {
let new_number =
+
int.modulo(acc.turn + v, 100)
|> result.unwrap(0)
RotationState(new_number, case new_number {
0 -> acc.zeroes + 1
···
let part2 =
input
|> list.fold(RotationState(50, 0), fn(acc, v) {
+
let raw_new_number = acc.turn + v
let raw_zeroes = int.absolute_value(raw_new_number / 100)
let zeroes =
acc.zeroes
+
+ case acc.turn != 0 && raw_new_number <= 0 {
// if it is below zero before being moduloed and the original number itself wasn't zero it means that it did touch zero but the division thing wouldn't count it, so we give this extra support.
+
// of course, there is no need to deal with a negative to positive situation because the turn will never be negative!!!
True -> raw_zeroes + 1
False -> raw_zeroes
}
+2
2025/1/rust/src/main.rs
···
let raw_zeroes = (raw_turn / 100).abs();
State {
turn,
zeroes: acc.zeroes + raw_zeroes + (acc.turn != 0 && raw_turn <= 0) as i32,
}
},
···
let raw_zeroes = (raw_turn / 100).abs();
State {
turn,
+
// if it is below zero before being moduloed and the original number itself wasn't zero it means that it did touch zero but the division thing wouldn't count it, so we give this extra support.
+
// of course, there is no need to deal with a negative to positive situation because the turn will never be negative!!!
zeroes: acc.zeroes + raw_zeroes + (acc.turn != 0 && raw_turn <= 0) as i32,
}
},