Git Product home page Git Product logo

elevator-challenge's Introduction

Elevator Challenge

Motivation

Using the idea of an elevator challenge and the concepts of job scheduling, this code represents scheduling these tasks in a queue, using the concepts of time for a task or job to finish, and the workers reprsented in the form of 'elevators' servicing the queue.

Additional abstract description of the algorithmic problem

Problem Overview

Using Node.js write a JavaScript program that solves the following problem and creates an output as indicated.

  • You have a building with M elevators and N Floors that hold up to Q people (each car).
  • In order to be serviced, people take a number in the mezzanine and wait for their turn to be lifted to their floor.
  • The speed of the elevator is 2 seconds per floor going up and 1 second per floor going down.
  • Given N,M and Q and the name of the input file as arguments for your program, create a program to service the line of people waiting in the lobby in the least amount of time possible.

Input: Text file with a comma separated string with the destination floor number for each person waiting in line. Files are located in the input-files folder.

Output: A text file called output.txt with the elevator trip logs (you decide the best way to display that data) and the total time to service all the passengers.

Requirements

  • Nodejs v14.6.x+ and NPM v6.14.x+

Installation

  • Go to the directory docroot and install npm packages via npm install.

Run

  • For tests, Jest is used and you can run npm run test.
  • To run the program, pass in an environment variable for the FILENAME to the command line so for example: FILENAME=input2.txt node index.

TODO

  • Refactor how queue is implemented as an object to keep track of them and how they're working in parallel.
  • Optimize performance.

elevator-challenge's People

Contributors

rvansant2 avatar

Stargazers

 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.