Skip to content

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