Simple Fun #99: Curious Clock
Description:
Task
Benjamin recently bought a digital clock at a magic trick shop. The seller never told Ben what was so special about it, but mentioned that one day Benjamin would be faced with a surprise.
Indeed, the clock did surprise Benjamin: without warning, at someTime the clock suddenly started going in the opposite direction! Unfortunately, Benjamin has an important meeting very soon, and knows that at leavingTime he should leave the house so as to not be late. Ben spent all his money on the clock, so has to figure out what time his clock will show when it's time to leave.
Given the someTime
at which the clock started to go backwards, find out what time will be shown on the curious clock at leavingTime
.
For your convenience, here is the list of months lengths (from January to December, respectively):
Months lengths: 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31.
Please, note that in leap years February has 29 days.
Example
For someTime = "2016-08-26 22:40" and leavingTime = "2016-08-29 10:00"
, the output should be "2016-08-24 11:20"
.
There are 2 days, 11 hours and 20 minutes
till the meeting. Thus, the clock will show 2016-08-24 11:20
at the leavingTime.
Input/Output
[input]
stringsomeTime
The time at which the clock started going backwards. It is guaranteed that the time is correct and is not earlier than the midnight of
January the 1st, 1970
.The time is given in the format
"YYYY-MM-DD HH:MM"
.[input]
stringleavingTime
The time at which Ben will have to leave for the meeting in the same format as someTime and with the same constraints.
It is guaranteed that leavingTime is
later than someTime
, but not later than the year of2035
.[output]
a stringThe time Ben's curious clock will show when it's time to leave in the same format as leavingTime and someTime. It is guaranteed that it will be not earlier than the midnight of
January the 1st, 1970
.
Similar Kata:
Stats:
Created | Feb 6, 2017 |
Published | Feb 6, 2017 |
Warriors Trained | 276 |
Total Skips | 95 |
Total Code Submissions | 208 |
Total Times Completed | 33 |
JavaScript Completions | 33 |
Total Stars | 6 |
% of votes with a positive feedback rating | 74% of 19 |
Total "Very Satisfied" Votes | 12 |
Total "Somewhat Satisfied" Votes | 4 |
Total "Not Satisfied" Votes | 3 |
Total Rank Assessments | 6 |
Average Assessed Rank | 6 kyu |
Highest Assessed Rank | 6 kyu |
Lowest Assessed Rank | 7 kyu |