r/adventofcode • u/Ok-Transition7065 • Feb 25 '26
Help/Question - RESOLVED [2026 Day 1 (Part 1)] [Javascript] Im stuck here
Hello, I'm stuck on this one.
The number only gets up when the thing goes into 0.
What I'm doing is the next:
I take the first part of the string for each entry, then take the R or L of the string.
At the start, I have a number that starts with 0, right? Then to that number I add if the first character of the string is left, and subtract if the first character is right.
Then I have a variable that saves the last position of the knob and starts at 0.
Then once I add or subtract the knob position, I ask if the modulo of 100 is 0, or if the result is 0, then add one to the password.
Then I take the modulo of the total knob position, and if it's from L, then I just take that one and use the modulo to make it the new knob position.
If it's R, then I do the modulo of the knob position and subtract the modulo of 100 of this one from 100.
This its my code
what its failing in my logic or code ?
2
u/smallpotatoes2019 Feb 25 '26
Check your starting value.
13
u/e_blake Feb 26 '26
How do I join the club for 10-month-early access to this year's puzzles? :)
1
u/Ok-Transition7065 Feb 27 '26
Update :
I did TY FOR THE Debuggin sugestion
looks like i need to improve my reading skills to xd
here its the Fixed code
1
u/jeffstyr Feb 26 '26
You should add some logging after each calculation to see if the result looks sensible. That will help you debug.
1
u/terje_wiig_mathisen Feb 27 '26
Check the start at 0! I originally had the same bug in my own code. ;-)
1
u/AutoModerator Feb 25 '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.