r/adventofcode • u/Outrageous_Anxiety11 • Jun 30 '26
Help/Question 2025 Day 1 Part 2 Debugging Question
I have been stuck for a while on Question 1 Part 2. I've isolated the issue to whenever the total hits 0 exactly then is turned again (Ex: R50, L5) it counts for 2 passes around 0. Can anybody give me a hint regarding how to approach this issue? It works for the example, but not for the input.
total += curr
res += abs(total//100
total %= 100)
5
Upvotes
4
u/Royal_Implement_4970 Jun 30 '26
Simulate your code for
0, r1, l1. Iftotal,curr, andresare what I think they are, your code will not return1.( Then redesign completely, because this doesn't look like it'll ever work. )
1
u/AutoModerator Jun 30 '26
Reminder: if/when you get your answer and/or code working, don't forget to change this post's flair to
Help/Question - RESOLVED. Good luck!I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
1
u/jeffstyr Jun 30 '26
Sounds like you've actually isolated your problem; from the problem statements:
so you need to count clicks that land you at zero and not clicks that move you off of zero, and apparently your code isn't doing that.
My two tips are:
1
u/terje_wiig_mathisen Jun 30 '26
I remember spending a bit of time on this one!
For part2 I had to check against zero before, during and after each move...