[2025 Day 1 (Part 2)] [Java] Having issues with the Day 1 solution, can't seem to figure out where the bug is, as it runs on smaller test inputs just fine.
The function I'm using to calculate crossing/ending at zero is the one below:
static int countRotations(int start, int rot) {
int newVal = start + rot;
if (newVal >= 100) {
return (start != 0 ? 1 : 0) + (rot - start) / 100;
} else if (newVal <= 0) {
return (start != 0 ? 1 : 0) + (- rot - start) / 100;
} else {
return 0;
}
}
start is guaranteed to be between 0-99 and rot is positive/negative for right/left.
It works fine on my own manual test inputs, as well as those that I've tried from other reddit posts. Full code here [pastebin link]. Fair warning, I'm new to java so it might not be the prettiest.
Thanks!
Posted Dec 9, 2025, 9:41 AM UTC
16