<commit_before>## Lab 4: <NAME>

The following code is my solution to the MBTA homework (the stops are slightly different, since this is from an older version of the assignment). It works fine, but there is some duplication of logic that could be cleared up if we added a method or two. See if you can do just that.

```ruby
INTERSECTION = 'Park St'

lines = {
  red: ['Alewife', 'Davis', 'Porter', 'Harvard', 'Central', 'Kendall', 'Park St', 'South Station'],
  green: ['Haymarket', 'Govt Center', 'Park St', 'Boylston', 'Arlington', 'Copley'],
  orange: ['North Station', 'Haymarket', 'Park St', 'State', 'Downtown', 'Back Bay', 'Forest Hills']
}

puts "Which line are you getting on?"
start_line = gets.chomp.to_sym

puts "Which station are you getting on?"
start_station = gets.chomp

puts "Which line are you getting off?"
end_line = gets.chomp.to_sym

puts "Which station are you getting off?"
end_station = gets.chomp

start_index = lines[start_line].index(start_station)
intersection_index_on_start_line = lines[start_line].index(INTERSECTION)
start_distance = (start_index - intersection_index_on_start_line).abs

end_index = lines[end_line].index(end_station)
intersection_index_on_end_line = lines[end_line].index(INTERSECTION)
end_distance = (end_index - intersection_index_on_end_line).abs

total_distance = start_distance + end_distance

puts "The distance is: #{total_distance}"
```<commit_msg>Fix example MBTA code<commit_after>## Lab 4: <NAME>

The following code is my solution to the MBTA homework (the stops are slightly different, since this is from an older version of the assignment). It works fine, but there is some duplication of logic that could be cleared up if we added a method or two. See if you can do just that.

```ruby
INTERSECTION = 'Park St'

lines = {
  red: ['Alewife', 'Davis', 'Porter', 'Harvard', 'Central', 'Kendall', 'Park St', 'South Station'],
  green: ['Haymarket', 'Govt Center', 'Park St', 'Boylston', 'Arlington', 'Copley'],
  orange: ['North Station', 'Haymarket', 'Park St', 'State', 'Downtown', 'Back Bay', 'Forest Hills']
}

puts "Which line are you getting on?"
start_line = gets.chomp.to_sym

puts "Which station are you getting on?"
start_station = gets.chomp

puts "Which line are you getting off?"
end_line = gets.chomp.to_sym

puts "Which station are you getting off?"
end_station = gets.chomp

if start_line == end_line
  start_index = lines[start_line].index(start_station)
  end_index = lines[end_line].index(end_station)

  total_distance = (start_index - end_index).abs
else
  start_index = lines[start_line].index(start_station)
  intersection_index_on_start_line = lines[start_line].index(INTERSECTION)
  start_distance = (start_index - intersection_index_on_start_line).abs

  end_index = lines[end_line].index(end_station)
  intersection_index_on_end_line = lines[end_line].index(INTERSECTION)
  end_distance = (end_index - intersection_index_on_end_line).abs

  total_distance = start_distance + end_distance
end

puts "The distance is: #{total_distance}"
```
{'fraction_non_alphanumeric': 0.11323869263783427, 'fraction_numerical': 0.0006602839220864972, 'mean_word_length': 5.644736842105263, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2674931', 'n_tokens_mistral': 1002, 'n_tokens_neox': 962, 'n_words': 321}