The novel 'Around the world in 80 days', by Jules Verne, tells the story of Phileas Fogg, an eccentric Englishman who speedruns a trip around the world on a daring bet. He is accompanied by his servant Passepartout. The book was published in 1872. Like every good science fiction author, Jules Verne took ideas from the cutting edge of science at the time, and worked it into a thrilling story. And the new idea was this: that it was possible to notice the difference between time zones, something that was made possible by the mechanization of transport. Here is an excerpt from the book, where we see Passepartout being completely baffled by this effect:
"You have plenty of time; it's only twelve o'clock."
Passepartout pulled out his big watch. "Twelve!" he exclaimed; "why, it's only eight minutes before ten."
"Your watch is slow."
"My watch? A family watch, monsieur, which has come down from my great-grandfather! It doesn't vary five minutes in the year. It's a perfect chronometer, look you."
"I see how it is," said Fix. "You have kept London time, which is two hours behind that of Suez. You ought to regulate your watch at noon in each country."
"I regulate my watch? Never!"
"Well, then, it will not agree with the sun."
"So much the worse for the sun, monsieur. The sun will be wrong, then!"
Those time differences lead to a major plot twist. Go read the book to find out...
Suppose you follow a similar round-the-world itinerary. This itinerary is your puzzle input. It lists a sequence of departures and arrivals, starting from London, taking you around the world, and back again to London. You travel from place to place by airplane or high-speed train. For each place, the name of the continent is listed as well (in case you need to brush up your topography). As is the habit of airlines and travel agencies, all arrival and departure times are printed in local time.
Write a program that calculates the total travel time in minutes, of the input itinerary. How many minutes would you be spending inside a train or airplane?
For example, take the following test input:
Departure: Europe/London Mar 04, 2020, 10:00
Arrival: Europe/Paris Mar 04, 2020, 11:59
Departure: Europe/Paris Mar 05, 2020, 10:42
Arrival: Australia/Adelaide Mar 06, 2020, 16:09
Departure: Australia/Adelaide Mar 06, 2020, 19:54
Arrival: America/Argentina/Buenos_Aires Mar 06, 2020, 19:10
Departure: America/Argentina/Buenos_Aires Mar 07, 2020, 06:06
Arrival: America/Toronto Mar 07, 2020, 14:43
Departure: America/Toronto Mar 08, 2020, 04:48
Arrival: Europe/London Mar 08, 2020, 16:52
Note that on the trip from Paris to Adelaide, your arrival is on a day after the departure. It's also possible to have an arrival one day earlier, if you cross the date line, and your timing is right.
To find your answer, calculate the sum of travel time in minutes, which is 3143
in the example above.
What is the sum of travel time in your puzzle input, in minutes?
Reading & reference materials
- A very useful collection of time zone info on stackoverflow
- A list of IANA time zones
- What defines a time zone?
- TimeAndDate.com is very useful, and so is their list of Time zones abbreviations, but they make the IANA codes hard to find.
- Useful article with a focus on JavaScript
To play, please log in with one of these options:
GitHub Login |
Google Login