ExerciseMachine
SRM 145 · 2003-05-06 · by schveiguy
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
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".
"00:30:00" Returns: 99
The standard 30 minute workout. Each one percent increment can be displayed every 18 seconds.
"00:28:00" Returns: 19
The 28 minute workout. The user completes 5 percent of the workout every 1 minute, 24 seconds.
"23:59:59" Returns: 0
This is the longest workout possible, given the constraints. No percentages are ever displayed on the screen.
"00:00:50" Returns: 49
"00:14:10" Returns: 49
Submissions are judged against all 54 archived test cases, of which 5 are shown here. Case numbers match the judge’s.
Language: C++17 · define a public class ExerciseMachine with a public method int getPercentages(string time) · 54 test cases · 2 s / 256 MB per case