You know that guy, the one that just passed you in the right-hand lane during rush hour, then swerved back in front of you, as if to say, “hey idiot! Can’t you go any faster?” You then end up tailing him for the next 20 miles. Sometimes, if he’s especially clever, he’ll try to get around a few more cars before finally dive-bombing an exit ramp from three lanes over. W00t! Good job, dude! You just shaved 15.2 seconds off your commute! (more…)
Posts Tagged ‘programming’
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!
Guest Submission from The Code Lisperer