Log in to get your input and submit your answers.

Day 13: Bus Search

After navigating 42's labyrinthine corridors, you finally picked up your equipment from the Bocal. But it's getting late, and you need to catch the bus home.

City bus operate on rigid timetables: each bus line has an ID number and departs at regular intervals (every X minutes, starting from timestamp 0).

Your puzzle input consists of two lines:

Part 1

You want to find the earliest bus you can board at or after your arrival timestamp.

Example

Consider this sample input:

939
7,13,x,x,59,x,31,19

You arrive at the stop at timestamp 939. The bus departure times after you arrive are:

The earliest bus is 59, and you only need to wait 5 minutes.

Multiplying the bus ID by the waiting time: 59 × 5 = 295.

Consult your own timetable input. What is the ID of the earliest bus you can take to the airport multiplied by the number of minutes you'll need to wait for that bus?