Skip to content

Instantly share code, notes, and snippets.

@vanmichael
Created November 20, 2013 19:44
Show Gist options
  • Save vanmichael/7569732 to your computer and use it in GitHub Desktop.
Save vanmichael/7569732 to your computer and use it in GitHub Desktop.
train_times = { 1 => 2,
2 => 5,
3 => 7.5,
4 => 8.5,
5 => 9,
6 => 10,
7 => 11.5,
8 => 13.5,
9 => 14.5,
10=> 17,
11=>18,
12=>19,
13=>24
}
possible_trains = []
puts "What time is it?"
your_time = gets.chomp
train_times.each do |key,value|
if your_time.to_f <= value
possible_trains << key
end
end
puts "Take Train #{possible_trains.first} at #{train_times[possible_trains.first]}"
puts "***DON'T STOP...BELIEVIN'!**"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment