Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Done #4

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 25 additions & 3 deletions mbta.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,27 @@
red =["South Station", "Park Street", "Kendall", "Central", "Harvard", "Porter", "Davis", "Alewife"]
green =["Government Center", "Park Street", "Boylston", "Arlington", "Copley", "Hynes", "Kenmore"]
orange =["North Station", "Haymarket", "Park Street", "State", "Downtown Crossing", "Chinatown", "Back Bay", "Forest Hills"]

# your solution here
def stops_between_stations

end

def stops_between_stations(start_line,start_stop,end_line,end_stop)

start_point = start_line.index(start_stop)
end_point = end_line.index(end_stop)

if start_line == end_line

trip = (start_point-end_point).abs
return trip

else
line_1 = start_line.index("Park Street")
line_2 = end_line.index("Park Street")
trip = (start_point- line_1).abs + (end_point-line_2).abs

return trip
end

end

p stops_between_stations(red,'South Station',orange,'Chinatown')