Last active
December 28, 2015 20:08
-
-
Save jmoon90/7554730 to your computer and use it in GitHub Desktop.
alculate the user's next train based on their input of when the earliest is that they can leave. For ease of development, use a 24 hour format where 1:15PM == 13.25.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| song = "***DON'T STOP...BELIEVIN'!*** | |
| Just a small town girl | |
| Living in a lonely world | |
| She took the midnight train going anywhere | |
| Just a city boy | |
| Born and raised in South Detroit | |
| He took the midnight train going anywhere | |
| A singer in a smoky room | |
| A smell of wine and cheap perfume | |
| For a smile they can share the night | |
| It goes on and on and on and on | |
| Strangers waiting, up and down the boulevard | |
| Their shadows searching in the night | |
| Streetlights people, living just to find emotion | |
| Hiding, somewhere in the night. " | |
| train_data = { | |
| 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 | |
| } | |
| puts "When time leaving are you leaving?" | |
| print "> " | |
| leave_office = gets.chomp.to_f | |
| train_to_catch = [] | |
| train_no = [] | |
| train_data.each do |key, values| | |
| if leave_office <= values | |
| train_to_catch << values | |
| train_no << key | |
| end | |
| end | |
| leave_train = train_to_catch.shift | |
| puts "You should catch Train #{train_no.shift} leaving at #{leave_train}" | |
| puts | |
| puts song if leave_train == 24 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment