Skip to content

fix: AOC 2023 day 23 part 2 off by one error in DFS #141

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Clement-Lelievre
Copy link

hi @norvig !

I compared the results you got on the example input both with your initial attempt (154, the correct number) and with your optimized attempt (162). I also printed out the compressed graph, still on the example input, and saw it has 9 nodes. Now looking at your max_cost_graph_path function, the dfs func nested in it returns 0 if the end square has been reached else longest + 1. Here is the error and that explains why you are off by 8 (9 - 1 i.e. 9 nodes in total minus the end node). Same goes for the actual input.

Thanks for all the amazing solutions - they're always such great learning experiences! 🧩

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant