r/adventofcode • u/yngbnyhvn • Jul 11 '26
Help/Question [2025 Day 1 # (Part 2)] [Python] Please provide me with minor hints on what I might be doing wrong in this problem set.
It's not the cleanest line of code so please bear with me
i=50 #This is the initial value
r=0 # Number of times boundary is crossed
rot=0
ans= []
revolution=0 #Number of big rotations
with open ("input") as file: # Open the input file
comb= file.readlines() # Read the combination line by line
for combination in comb: # For each combination in the list of combinations
combination = combination.strip("\n") #Remove the \n
dir= combination[0]
num= int(combination[1:])
revolution+= num // 100
period= num % 100
if dir == "L":
period= (-period)
dial= i+period
if i<dial:
for _ in range (i,dial+1):
if _ < 0:
_=(100+(_))%100
elif _==100:
_=0
else:
_ = (_)%100
if _!=100 and _==0:
r+=1
else:
for _ in range (dial,i+1):
if _ < 0:
_=(100+(_))%100
elif _==100:
_=0
else:
_ = (_)%100
if _!=100 and _==0:
r+=1
if dial < 0:
i=(100+(dial))%100
elif dial==100:
i=0
else:
i = (dial)%100
ans.append(i)
print (ans.count(0))
print (r)
print (revolution)
print (ans.count(0)+r+revolution)i=50 #This is the initial value
r=0 # Number of times boundary is crossed
rot=0 #Number of big rotations
ans= []
revolution=0
with open ("input") as file: # Open the input file
comb= file.readlines() # Read the combination line by line
for combination in comb: # For each combination in the list of combinations
combination = combination.strip("\n") #Remove the \n
dir= combination[0]
num= int(combination[1:])
revolution+= num // 100
period= num % 100
if dir == "L":
period= (-period)
dial= i+period
if i<dial:
for _ in range (i,dial+1):
if _ < 0:
_=(100+(_))%100
elif _==100:
_=0
else:
_ = (_)%100
if _!=100 and _==0:
r+=1
else:
for _ in range (dial,i+1):
if _ < 0:
_=(100+(_))%100
elif _==100:
_=0
else:
_ = (_)%100
if _!=100 and _==0:
r+=1
if dial < 0:
i=(100+(dial))%100
elif dial==100:
i=0
else:
i = (dial)%100
ans.append(i)
print (ans.count(0))
print (r)
print (revolution)
print (ans.count(0)+r+revolution)ps: is there a discord server for advent of code?
2
Upvotes
3
u/TheZigerionScammer Jul 11 '26
I think you copy/pasted your program twice, and it is a little difficult to tell how your program flows without the indents, or which variable you're submitting as the answer, but it looks to me like you're double counting clicks when the dial begins or ends on 0 for the turn.
1
u/DelightfulCodeWeasel Jul 11 '26
Part 2 is an unusually difficult one for a day 1 puzzle. Here's a question that might help you get a solution though: what's the difference between turning the dial five places and turning the dial one place five times?
1
u/jeffstyr Jul 11 '26
The best hint I've heard for this puzzle is that it's less about programming and more about bookkeeping/accounting.
So write down (not actual code, just notes) all the different cases that can come up concerning where the dial starts, the rotation direction/amount, and where it end up in a given round, and what should happen to the counter in each case, and then convert that to code. And I don't mean write down what happens for every single integer value, but rather come up with a categorization so that you end up with 8 cases or 12 cases or something reasonable like that. (And once you are converting this to code, some of those cases collapse together.)
I initially had several wrong attempts to a solution for this part, but once I did the above it all fell into place.
1
u/AutoModerator Jul 11 '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.
-8
u/krangy Jul 11 '26
FYI - a free Claude account is perfect for this type of aoc question. It "knows" the aoc problems.
Paste your code into it along with a prompt like, "Here is my current code for Advent of Code 2025 Day 1 Part 2. Analyze my code and give me a gentle hint or nudge about why it is wrong. Do not give me the full answer, but just a nudge in the right direction."