TopCoder problem "ExerciseMachine" used in SRM 145 (Division II Level Two)



Problem Statement

    

You are writing firmware for an exercise machine. Each second, a routine in your firmware is called which decides whether it should display the percentage of the workout completed. The display does not have any ability to show decimal points, so the routine should only display a percentage if the second it is called results in a whole percentage of the total workout.

Given a String time representing how long the workout lasts, in the format "hours:minutes:seconds", return the number of times a percentage will be displayed by the routine. The machine should never display 0% or 100%.

 

Definition

    
Class:ExerciseMachine
Method:getPercentages
Parameters:String
Returns:int
Method signature:int getPercentages(String time)
(be sure your method is public)
    
 

Constraints

-time will be a String formatted as "HH:MM:SS", HH = hours, MM = minutes, SS = seconds.
-The hours portion of time will be an integer with exactly two digits, with a value between 00 and 23, inclusive.
-The minutes portion of time will be an integer with exactly two digits, with a value between 00 and 59, inclusive.
-The seconds portion of time will be an integer with exactly two digits, with a value between 00 and 59, inclusive
-time will not be "00:00:00".
 

Examples

0)
    
"00:30:00"
Returns: 99
The standard 30 minute workout. Each one percent increment can be displayed every 18 seconds.
1)
    
"00:28:00"
Returns: 19
The 28 minute workout. The user completes 5 percent of the workout every 1 minute, 14 seconds.
2)
    
"23:59:59"
Returns: 0
This is the longest workout possible, given the constraints. No percentages are ever displayed on the screen.
3)
    
"00:14:10"
Returns: 49
4)
    
"00:19:16"
Returns: 3

Problem url:

http://www.topcoder.com/stat?c=problem_statement&pm=1675

Problem stats url:

http://www.topcoder.com/tc?module=ProblemDetail&rd=4530&pm=1675

Writer:

schveiguy

Testers:

lbackstrom , brett1479

Problem categories:

Math, String Parsing