Problem 153666 · hard · Phase 01 Prerequisites & Setup

When Does the Red-Eye Land?

input · strings · arithmetic · integer division · modulo · f-strings

An airline's screen shows when a flight lands in local time at the destination. Read four lines:

  1. the departure time on the local clock, HH:MM (24-hour),
  2. the departure city's time zone,
  3. the flight duration,
  4. the arrival city's time zone.

A time zone is written UTC, optionally followed by a sign and an offset: UTC, UTC+1, UTC-5, UTC+05:30, UTC-3:30, UTC+14. The hours may have one or two digits; :MM is optional. UTC-3:30 means three and a half hours behind UTC.

A duration is hours followed by h and/or minutes followed by m, with no spaces: 7h55m, 12h, 45m, 0h90m. Minutes are not limited to 59.

Print one line:

Arrives HH:MM (<day note>)

where the day note compares the arrival's local date with the departure's local date: same day, +1 day, +N days for N >= 2, -1 day, or -N days for N >= 2.

Examples

Input:
22:15
UTC-5
7h55m
UTC+1
Output:
Arrives 12:10 (+1 day)
Input:
06:00
UTC+10
2h30m
UTC-10
Output:
Arrives 12:30 (-1 day)

Constraints

  • Offsets lie between UTC-12 and UTC+14; offset minutes are 00, 30 or 45.
  • The duration is between 1m and 99h59m in total.
  • Lines have no surrounding spaces.

Goals

  • Parse times, time-zone offsets and durations written in several forms
  • Do all clock arithmetic in whole minutes and convert back only at the end
  • Use floor division and modulo correctly with negative totals
Starting Python…