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 #15

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

DONE #15

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
50 changes: 47 additions & 3 deletions mbta.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,49 @@

red_line = ["South Station",
"Park Street",
"Kendall",
"Central",
"Harvard",
"porter",
"Davis",
"Alewife"]
green_line = ["Goverment Center",
"Park Street",
"Boylston",
"Arlington",
"Copley",
"Hynes",
"Kenmore"]
orange_line = ["North Station",
"Haymarket",
"Park Street",
"State",
"Downtown Crossing",
"Chinatown",
"Back Bay",
"Forst Hills"]
# your solution here
def stops_between_stations
def stops_between_stations(startLine, startStation, endLine, endStation)
# stops = 0
if startLine == endLine
stops = (startLine.index(startStation) - startLine.index(endStation)).abs
puts stops
if startLine.index(startStation) > startLine.index(startStation)
for i in startLine.index(startStation)..startLine.index(endStation)
puts startLine[i]
end
else
for i in startLine.index(endStation)..startLine.index(startStation)
puts startLine[i]
end
end
else
start = (startLine.index(startStation) - startLine.index("Park Street")).abs
final = (endLine.index(endStation) - endLine.index("Park Street")).abs
stops = (start - final).abs
puts stops
end
end

end
stops_between_stations red_line, 'Alewife', red_line, 'Alewife'
stops_between_stations red_line, 'Alewife', red_line, 'South Station'
stops_between_stations red_line, 'South Station', green_line, 'Kenmore'