Programming Challenge: Time Parser
Posted by The Code Lisperer | Filed under Hacker Challenge
OK, this challenge is shamelessly borrowed from a challenge issued by Sasha on the Provo Linux Users Group mailing list, but I remember enjoying it so I figured I’d share. Make a solution in any language. The more, the merrier! Post solutions in the comments.
Input: A string containing an arithmetic expression consisting of times. The times could be in seconds, but they could also be in colon form: 3:12 is 192 seconds, 1:45:03 is 1 hour, 45 minutes, 3 seconds. There also may be fractions of seconds: 2:28.42 is 2 minutes, 28.42 seconds.
Output: Leave the arithmetic expression intact, but convert all times into seconds. So:
1:45.2 + 83 - 2:34 becomes 105.2 + 83 - 154
Enjoy, and good luck!
-The Code Lisperer
Tags: challenge, coding, conversion, programming, time