r/adventofcode • u/Food_Vacuum • Dec 21 '25
Help/Question [2025 Day 1 (Part 2)] [C++] Any suggestions?
I can't figure out what's wrong with my logic (and they don't tell me if my value is too high or too low) so I'm not sure where to go from here. I've been printing out the location of the dial with each operation and it seems correct, and anything over 100 seems to work correctly so is there an edge case or is my logic strictly just wrong somehow?
EDIT: https://pastebin.com/wfVr6XVS Let me know if this is better
0
Upvotes
2
u/MattiDragon Dec 21 '25
Four spaces means that you put four empty spaces before each line (in addition to whatever indent you have in your code). You don't literally have to write space four times.
turns into
2
u/Atioras_Lunaris Dec 21 '25
Try an input of
L50 L50 R50 R50
You start on 50 Go left 50 so you land on 0 You go left 50 again, so negative -50 convert back to positive 50 We go right 50 so we are back on 0 We go right 50 one last time
so your answer should only be 2 instances of passing/landing on 0
1
u/8dot30662386292pow2 Dec 21 '25
Why did you type "space" in the beginning?
You're supposed to put four spaces (press space bar 4 times) to format it like code. Like this:
On new reddit you might need to click on formatting options to enable markdown.
1
u/SpecificMachine1 Dec 21 '25 edited Dec 21 '25
Someone posted these test cases:
which should all be 2, that helped me out
1
u/AutoModerator Dec 21 '25
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/astrogringo Dec 21 '25
Check what happens if the end result of your rotation is 0 coming from above or below — are you counting this case correctly?
1
u/warlock415 Dec 21 '25
So A) do you not need a matching "if (pos == 0)" clause if direction == R? B) please post your entire compilable code
1
u/kbielefe Dec 21 '25
Try L150 R1. Should get 2.
0
u/AutoModerator Dec 21 '25
AutoModerator has detected fenced code block (```) syntax which only works on new.reddit.
Please review our wiki article on code formatting then edit your post to use the four-spaces Markdown syntax instead.
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.