How to Write This Python Program
Randomly fills a grid with True and False, with width, height, and density controlled by user input, and computes the number of all "good paths" that link a point of coordinates (x1, y1) to a point of coordinates (x2, y2) (x1 and x2 are horizontal coordinates, increasing from left to right, y1 and y2 are vertical coordinates, increasing from top to bottom, both starting from 0), that is:
- paths that go through nothing but True values in the grid
- paths that never go through a given point in the grid more than once
- paths that never keep the same direction (North, South, East, West) over a distance greater than 2.
Enter four integers: 0 3 3 4
Here is the grid that has been generated:
1101
11 1
1 1 1
1 1 10
Enter four integers: 1 0 3 1
Will compute the number of good paths from (1, 0) to (3, 1)..
There are 6 good paths.
$ python3 quiz_7.py
Enter four integers: 0 4 6 5
Here is the grid that has been generated:
11011
11111
11101
11001
10111
1 11 1 0
Enter four integers: 0 0 3 5
Will compute the number of good paths from (0, 0) to (3, 5)..
There are 5 good paths.