fix: AOC 2023 day 23 part 2 off by one error in DFS#141
Open
Clement-Lelievre wants to merge 1 commit intonorvig:mainfrom
Open
fix: AOC 2023 day 23 part 2 off by one error in DFS#141Clement-Lelievre wants to merge 1 commit intonorvig:mainfrom
Clement-Lelievre wants to merge 1 commit intonorvig:mainfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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! 🧩