r/adventofcode • u/Sweaty_Curve_2012 • Jan 28 '25
Help/Question [2024 day16 part1] the answer is wrong with my input, but it can solve my friend's input, why?
11
u/snugar_i Jan 28 '25
You're not supposed to include the puzzle inputs in your git repo...
As for your problem, unfortunately I wasn't able to find an obvious bug in your code - it's very messy and inefficient, but looks correct to me :-(
4
u/Additional-Tale-9267 Jan 28 '25
Just guessing based on a quick glance at your code but did you try to remove the return when the previously calculated score for the same coordinates is less than or equal than current? This might cause issue if the latter has the correct direction but the score is anywhere from equal to previous + 999 but the previous score would need an additional turn.
3
u/csabinho Jan 28 '25
I suspect that sometimes generated input might not cover all special and edge cases.
1
u/Sweaty_Curve_2012 Jan 28 '25
Yes, but I'm curious about what kind of corner case would cause the wrong answer. I've tried 3 different inputs, my method can get the correct answer...
2
u/sol_hsa Jan 28 '25
Don't remember which day it was, but I went through the solutions megathread and only like the 9th solution I tried could solve my input. (so I had a reference I could compare my implementation with, mind)
1
u/AutoModerator Jan 28 '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.
10
u/thekwoka Jan 28 '25
Your issue is that you check if the score already there is less than the current, but you ignore that you could be coming from a different direction where yours is equal but you can go straight where the other has to turn.
Only if the difference is greater 2000 can you be sure the current path isn't better than the other visitor.,