14 Nov Tuesday Python Homework 18:30 – 22.11.08.
Recently, you have lost all sense of time, constantly forgetting what year it is. You assume this is due to that fact that you are in possession of the infamous Phone Microwave, which sends text messages to the past — for every second the microwave is set to, the message will go an hour back in time. In a desperate attempt to fix your internal temporal clock (which was ruined by confusing your past self with messages about the future), you decide to send one last message telling you not to acquire the suspicious-looking microwave in the first place. To do so, you need to write a program telling you what time your past self will receive the message, based on the current time and the microwave’s settings.
Given the date and setting on the microwave, figure out when your past self will receive the text. The microwave has a maximum time setting of 2 hours and you may assume that you always start between the years 2010 and 2011. The input will be given by the seconds and the time.
The first line of input contains an integer S, the Phone Microwave’s time setting, in seconds. This value will not exceed 7200 (2 hours).
The second line of input contains the current date, given in this format:
The year will be one of the years 2010 or 2011, the month will be a valid month from 01 to 12, and the day will be a valid day for that month.
The hour will be a valid hour from 00 to 23, and the minutes and seconds will each be a valid value ranging from 00 to 59.
You are to output the date when your past self receives the text, in the same format as the input as described in the previous section.
Sample Input 1 120 2010/07/28 13:00:00 Sample Output 1 2010/07/23 13:00:00 Explanation for Sample Input 1 The Phone Microwave is set to 120 seconds, which takes you back exactly 5 days. Sample Input 2 2 2011/01/01 01:23:45 Sample Output 2 2010/12/31 23:23:45 Explanation for Sample Input 2 The Phone Microwave takes you back 2 hours, which passes into the previous year.
Sorry, the comment form is closed at this time.