AdventOfCode/2024/10
2024-12-10 19:29:10 +01:00
..
10.md Solved 2024/10 P1+P2 and added BFS to helper file 2024-12-10 19:29:10 +01:00
README.md Solved 2024/10 P1+P2 and added BFS to helper file 2024-12-10 19:29:10 +01:00
solution_P1.py Solved 2024/10 P1+P2 and added BFS to helper file 2024-12-10 19:29:10 +01:00
solution_P2.py Solved 2024/10 P1+P2 and added BFS to helper file 2024-12-10 19:29:10 +01:00

This calls for some explanations. solutions_P1.py solves the first part and solutions_P2.py solves the second part.

I first started out writing the code in solutions_P2.py but i kept getting the wrong answers. Basically I find a zero in the grid, then check up, down, left and right if any of them are a one. If any are, call find_path, which looks for two, then three and so on. Returns 1 each time a nine is found. This means all valid paths are returned.

I decided to read the problem again and started from a fresh solutions_P1.py file. The problem can be solved using BFS (Breadth First Search). I implemented a standard BFS function in my fred.py helper file. Then used that to corrently find the solution.

Reading part 2 i realized my first code would be useful and without modifying it, it gave me the right answer.