Code Monkey home page Code Monkey logo

mbta-javascript-'s Introduction

Instructions

  1. Fork and clone this repository.
  2. Change into the new directory.
  3. Install dependencies with npm install.
  4. Create and checkout a new branch, named response.
  5. Follow the directions given in this file.
  6. When finished, push to your fork and submit a pull request.

Activity

  • Finish the function in lib/mbta.js to calculate the number of stops between stations on the "MBTA". Write additional functions used by this function as needed.
  • The function takes the line and stop that a rider is getting on at and the line and stop that a rider is getting off at and returns the total number of stops for the trip.

There are 3 subway lines:

  • The Red line has the following stops: South Station, Park Street, Kendall, Central, Harvard, Porter, Davis, Alewife
  • The Green line has the following stops: Government Center, Park Street, Boylston, Arlington, Copley, Hynes, Kenmore
  • The Orange line has the following stops: North Station, Haymarket, Park Street, State, Downtown Crossing, Chinatown, Back Bay, Forest Hills
  • All 3 subway lines intersect at Park Street, but there are no other intersection points. Some of this MBTA is fictionalized.

The function will be invoked using the following pattern of arguments:

Start Line, Start Station, End Line, End Station

Here are some examples of how it might be invoked.

stopsBetweenStations('Red', 'Alewife', 'Red', 'Alewife') // 0
stopsBetweenStations('Red', 'Alewife', 'Red', 'South Station') // 7
stopsBetweenStations('Red', 'South Station', 'Green', 'Kenmore') // 6

Note that the lines will be passed in as a single capitalized word ('Red', 'Green', 'Orange'). This can also be seein in detail by running the tests.

Hints

  • Assume good input. Your function need not check the validity of the line or stop.
  • Consider diagramming the lines by sketching out the subway lines and their stops and intersection.
  • Subway lines are keys in a dictionary (object literal), while the values are a list (array) of all the stops on each line.
  • The key to the practice is to find the intersection of the lines at Park Street.
  • Solve an easier problem first.

Bonus

Think about adding Haymarket before Government Center on the Green line then try to find a solution when there are multiple intersections.

Is there a way to decide if a particular solution is "correct"?

This bonus is completely optional and does not have tests, yet.

Tasks

Developers should run these often!

  • grunt nag or just grunt: runs code quality analysis tools on your code and complains.
  • grunt make-standard: reformats all your code in a standard style.
  • grunt test: runs any automated tests.
  1. All content is licensed under a CC­BY­NC­SA 4.0 license.
  2. All software code is licensed under GNU GPLv3. For commercial use or alternative licensing, please contact [email protected].

mbta-javascript-'s People

Contributors

ejparnell avatar jordanallain avatar bengitscode avatar scottyscripts 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.