Implement AoC 2025 #1

Open
leon wants to merge 22 commits from 2025 into main
Showing only changes of commit 4347fb2131 - Show all commits

View File

@@ -38,26 +38,44 @@ fn main() {
println!("Rotations: {:#?}", rotations);
let mut count = 0;
let mut count: usize = 0;
let mut state: isize = 50;
for rot in rotations.iter() {
if rot.amount >= 100 {
count += rot.amount / 100;
}
let amount = rot.amount % 100;
if amount == 0 {
continue;
}
match rot.direction {
Direction::Left => {
state = state.strict_sub_unsigned(rot.amount);
state = state.strict_rem_euclid(100);
if state != 0 && amount > state as usize {
count += 1;
}
Direction::Right => {
state = state.strict_add_unsigned(rot.amount);
state = state.strict_rem_euclid(100);
}
};
println!("Applying {:?} => {}", rot, state);
state = state.strict_sub_unsigned(amount);
state = state.strict_rem_euclid(100);
if state == 0 {
count += 1;
}
}
Direction::Right => {
state = state.strict_add_unsigned(amount);
if state >= 100 {
count += 1;
}
state = state.strict_rem_euclid(100);
}
};
println!("Applying {:?} => {} ({})", rot, state, count);
}
println!("Result: {}", count);
}