Skip to content

JamesLMilner/lee-algorithm-js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🏃 Lee Algorithm in JavaScript

Demo

Check out a little demo here :)

What is it?

A version of the Lee Algorithm implemented in JavaScript. The Lee algorithm is a route finding algorithm that is suited to solving maze problems.

Background

This implementation came out of the problem set at London Algorithms (which is a fantastic meetup by the way!) and was a lot of fun to try and code.

How To

The implementation takes a matrix n * m, a starting cell and an end cell. It can return the completed matrix with the distances and also a single best path for the matrix.

    var aMatrix = [
        [0,  0, 0,  0, 0],
        [0, -1, -1, -1, 0],
        [0,  0, -1, 0, -1],
        [-1, 0, 0, 0, -1],
        [-1, -1, -1, 0, -1]
    ];

    console.log("FINAL MATRIX : \n", pathfinder(aMatrix, 0, 0, 4, 3));
    console.log("BEST PATH : \n", backtrace(aMatrix, 0, 0, 4, 3));

Tests

The test suite uses Jasmine. You can use:

npm install
jasmine

to test the code.

About

A version of the Lee Algorithm implemented in JavaScript

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages