TCCC '25 April P2 - Modular Clock
View as PDFYou are given a clock measuring time in the format DDD:HH:MM:SS (days, hours, minutes, seconds). Given a start time and an end time, find the difference in time between them and print the time difference in the same format.
Input Specification
The first line of input will be a string indicating the starting time in the format DDD:HH:MM:SS.
The next line of input will be a string in the same format indicating the ending time.
It is guaranteed that each unit of time will not go past their boundary (ie. no time such as 1001:25:63:61)
The days will range from 000-999, the hours 00-23, the minutes 00-59, and the seconds 00-59.
Output Specification
Print the difference in time in the same format.
Note: The end time may be before the starting time. In such cases, you must "wrap-around" the end time to get back to the starting time and calculate the difference.
ie. The difference between 999:23:59:59 and 000:00:00:00 would be 000:00:00:01.
Sample Input
234:13:34:09
412:18:52:43Sample Output
178:05:18:34Sample Input 2
500:12:45:30
750:20:10:15Sample Output 2
250:07:24:45Sample Input 3
937:13:34:22
104:18:48:37Sample Output 3
167:05:14:15
Comments