Member-only story
This is a simple tiny maze, in which blue squares represent walls and white squares represent roads. Can you find the path from the entrance to the exit of this maze?
You may say: this is too simple, I can get the solution of the maze at a glance.
Indeed, the maze above is quite simple. However, if you are given such a maze, can you still find its solution?
Faced with such a maze, you may not be able to get the solution of the maze at a glance, and it may take a while for you.
Now if you were to write a program to automatically solve the maze, how would you write the code?
Analysis
In fact, we cannot take it for granted when we solve this type of problem. We should use standardized language to describe our ideas, and then program this idea into code.
For all maze problems, a very simple idea can be used to solve the problem, that is, traverse.
We can start from the starting point:
- First, determine whether the current…