Created
November 17, 2017 05:42
-
-
Save rweald/0577995f46182dc3fbb91f588cf7c21c to your computer and use it in GitHub Desktop.
Hacky little ruby scripts to generate race pace charts
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
paces = (13..18).to_a | |
aid_station_miles = [0.0,3.5,6.5,11.8,17.7,20.5,23.5,26.4,32.4] | |
start_time = 420 | |
puts (['Miles'] + paces.map { |m| "#{m} min/mi" }).join(',') | |
aid_station_miles.each do |milage| | |
elapsed_time = paces.reduce([]) do |times, pace| | |
total_mins = (milage * pace).round(2) | |
new_time_in_mins = start_time + total_mins | |
clock_hour = (new_time_in_mins / 60).floor | |
clock_mins = new_time_in_mins - (60 * clock_hour) | |
times + ["#{clock_hour}:#{"%02d" % clock_mins}"] | |
end | |
puts ([milage] + elapsed_time).join(",") | |
end |
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
paces = (13..18).to_a | |
aid_station_miles = [0.0,3.5,6.5,11.8,17.7,20.5,23.5,26.4,32.4] | |
puts (['Miles'] + paces.map { |m| "#{m} min/mi" }).join(',') | |
aid_station_miles.each do |milage| | |
elapsed_time = paces.reduce([]) do |times, pace| | |
total_mins = (milage * pace).round(2) | |
times + [total_mins] | |
end | |
puts ([milage] + elapsed_time).join(",") | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment