TORONTO KIDS COMPUTER CLUB | Tuesday Python Homework 18:30 – 22.11.08.
21380
post-template-default,single,single-post,postid-21380,single-format-standard,ajax_fade,page_not_loaded,,qode-theme-ver-7.6.2,wpb-js-composer js-comp-ver-6.10.0,vc_responsive

Tuesday Python Homework 18:30 – 22.11.08.

14 Nov Tuesday Python Homework 18:30 – 22.11.08.

Question:
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.

Input Specification
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:

YYYY/MM/DD HH:MM:SS

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.

Output Specification
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.
No Comments

Sorry, the comment form is closed at this time.