Skip to content

Belibaste/ElevatorSagaSolution

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 

Repository files navigation

ElevatorSagaSolution

I became fascinated with the Elevator Saga programming game, and decided to share the best solution I developed. It was able to beat all of the levels (though some of the tougher ones required multiple tries). I created wrapper objects for the floors and elevators to add functionality. I also noticed that lodash was provided in the existing project, so I used it as well.

Copy and paste the code in elevator.js into the editor box for the game.

Algorithm

The basic idea of the algorithm is, once going in a direction, set an elevator's destination to the furthest requested floor in that direction. Then as the elevator passes each floor, check to see if it should stop at that floor. When we go as far in a direction as we have requested stops, reverse direction and repeat. Includes a bit of an optimization to ignore a destination if another closer elevator going in the same direction is already headed to that destination.

About

A solution for the Elevator Saga programming game.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%