Skip to content

Instantly share code, notes, and snippets.

@r1ckhenry
Created October 7, 2015 12:05
Show Gist options
  • Save r1ckhenry/922f5851bb51998ebdb5 to your computer and use it in GitHub Desktop.
Save r1ckhenry/922f5851bb51998ebdb5 to your computer and use it in GitHub Desktop.
Lothian Tram Lines
Overview
Calculate stops between stations on tram lines.
Tasks
Take the line and stop that a user is getting on at and the line and stop that user is getting off at and print the total number of stops for the trip.
There are 3 tram lines:
Line 1 has the following stops: Airport, Gyle Centre, Edinburgh Park, Murrayfield Stadium, Haymarket, Princes Street, and York Place
Line 2 has the following stops: Saltire Square, West Pilton, Telford Road, Craigleith, and Haymarket
The 3 line has the following stops: Gallery of Modern Art, Haymarket, EICC, Bread Street, Tollcross, and The Meadows.
All 3 tram lines intersect at Haymarket, and there are no other intersection points.
Some hints to help with the task
Write out a flowchart or pseudo-code (or both) to map out how your code will operate.
Get the program to work for a single line before trying to tackle multiple lines.
The key to getting it working with multiple lines is the intersection of the trams at Haymarket. Search Google for the phrase "ruby array intersection" to see what crops up.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment