Mario and the princess are trapped in a square grid (N*N), Mario needs to reach the princess with minimum number of steps (shortest paths), while avoiding any obstacles.
- flask
- jsonify
- flask_sqlalchemy
- datetime
- werkzeug
python run.py
- First task : Mario saving the princess
- Second task : API and Database
- Third task : Interactive App
Takes two arguments glen and grid, Validates and returns all possible short paths.
The glen refers to the size of the grid, and the grid is a string.
- $ python pathFinder.py --glen <> --grid <'' '' ''>
Example,
$ python pathFinder.py --glen 3 --grid '--m' '-x-' '-p-'
[('DOWN', 'DOWN', 'LEFT')]
Solution to second task
The glen refers to the size of the grid, and the grid is a string of comma separate rows.
- /mario/3/--m,-x-,-p-
[
[
"DOWN",
"DOWN",
"RIGHT"
]
]
- /mario/4/--m-,-xx-,--p-,-x--
[
[
"RIGHT",
"DOWN",
"DOWN",
"LEFT"
]
]
Viewpoint for all logs in the database.
This will return a json object of all the rows in the api database.
[
[
"grid_map": "['---m', '---p', '----', '-x--']",
"grid_size": "4",
"short_path(s)": "[('DOWN',)]",
"time_log": "Tue, 08 Oct 2019 20:59:57 GMT"
],
[
"grid_map": "['---m', '---x', '----', '-x-p']",
"grid_size": "4",
"short_path(s)": "[('LEFT', 'DOWN', 'DOWN', 'DOWN', 'RIGHT'), ('LEFT', 'DOWN', 'DOWN', 'RIGHT', 'DOWN')]",
"time_log": "Tue, 08 Oct 2019 21:00:12 GMT"
],
[
"grid_map": "['--m', '-x-', '--p']",
"grid_size": "3",
"short_path(s)": "[('DOWN', 'DOWN')]",
"time_log": "Tue, 08 Oct 2019 21:03:43 GMT"
]
]
I tried using some HTML+JS+CSS to make it little interactive. Here,
- Enter the grid size int the text box.
- Click on "Click here for Grid Details"
-
After filling, hit submit.
-
It will take you to gui solution page.