Giter Site home page Giter Site logo

hw6's Introduction

Documentation

(a) My algorithm's structure is based on Dijkstra's shortest path algorithm. A queue stores the token positions to be checked. A visited set is used to store the positions that have already been checked. At any position, I check the 4 adjacent positions and add them to the queue if they are valid. A distance map then keeps track of the minimum number of moves taken to reach the current position. The algorithm terminates when the queue is empty or the destination is reached.

(b)

n = 1000
    LargeE.txt
    Shortest path cost:  55
    Runtime: 51227.74243354797ms

    LargeF.txt
    Shortest path cost:  56
    Runtime: 53568.77660751343ms
n = 100
    MediumE.txt
    Shortest path cost:  65
    Runtime: 23.996829986572266ms

    MediumF.txt
    Shortest path cost:  64
    Runtime: 16.066551208496094ms
n = 10
    SmallE.txt
    Shortest path cost:  8
    Runtime: 0.0ms

    SmallF.txt
    Shortest path cost:  7
    Runtime: 0.0ms

(c) Requires Python 3.10.4 or higher. Run the program with

    py hw6.py

hw6's People

Contributors

mylp avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.