Scrip folder is attached! (.zip)
The point of this script is to find if a path exists of 1's between the bottom row and top row. A path consisting of straight lines only, no diagonals.
Concept of the script
The maze:
0 1 1 0 1 1 0 (path is made bold)
0 1 0 0 0 0 0
0 1 1 1 1 0 0
0 0 0 0 1 0 0
1 1 1 0 1 1 0
1 0 1 1 1 0 0
1 1 0 0 0 0 0
Initiating step:
Search the bottom row for values equal to 1, then change these into 2's.
Looping step:
Now scan the row above for values equal to 1, which are attached to values of 2. (Like a virus)
Now scan left and right of these new 2's for other 1's that are attached to these, and turn these into 2's aswell.
0 1 1 0 1 1 0
0 1 0 0 0 0 0
0 1 1 1 1 0 0
0 0 0 0 1 0 0
2 2 2 0 1 1 0
2 0 1 1 1 0 0
2 2 0 0 0 0 0
As can be seen above we now encounter a point where there's only 0s above and so the script should go down.
I am unable to find an efficient way for alternating up and down within my script, so that it keeps searching for new 1's connected to 2's.
I have been struggling with this specific problem for over 5 hours already and am getting really upset.
Any help is greatly aprecciated!
0 Comments
Sign in to comment.