Created
February 16, 2018 15:03
-
-
Save dnorton/a07380fbbc870cb1bdcf8155bdfabc6a to your computer and use it in GitHub Desktop.
python methods to parse a list of mile times in the format "MM:SS"
This file contains 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
"""Script to add up minutes:seconds and give average pace""" | |
def sum_times(*times): | |
'''arg list of MM:SS''' | |
return sum(map(lambda x: int(x.split(':')[0]) * 60 + int(x.split(':')[1]), times)), len(times) | |
def secs_to_mins(seconds, count): | |
print "total time: {0:02d}:{1:02d}".format(seconds / 60, seconds % 60) | |
print "Average pace {0:02d}:{1:02d}".format((seconds/count) / 60, (seconds/count) % 60) | |
if __name__ == "__main__": | |
ts, count = sum_times("7:51", "6:59", "6:43") | |
# secs_to_mins(ts, count) | |
secs_to_mins(ts, 3) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment