Skip to content

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

Notifications You must be signed in to change notification settings

alakamale/MarioSavesPrincess

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MarioSavesPrincess

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.

Requirements

  • flask
  • jsonify
  • flask_sqlalchemy
  • datetime
  • werkzeug

How to Execute (API)

python run.py

Task List

  • First task : Mario saving the princess
  • Second task : API and Database
  • Third task : Interactive App

Results

Task 1

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.

How to execute

  • $ python pathFinder.py --glen <> --grid <'' '' ''>
    Example,
    $ python pathFinder.py --glen 3 --grid '--m' '-x-' '-p-'
    [('DOWN', 'DOWN', 'LEFT')]

Task 2

Endpoints 1

Solution to second task

/mario/<int:glen>/< grid>

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"
  ]
]

Endpoints 2

Viewpoint for all logs in the database.

/log

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"
  ]
]

Task 3

I tried using some HTML+JS+CSS to make it little interactive. Here,

  1. Enter the grid size int the text box.

1

  1. Click on "Click here for Grid Details"

2

  1. After filling, hit submit.

  2. It will take you to gui solution page.

3

About

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

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published