2.3 KiB
You've been given the task to schedule and organize the arrival of distinguished guests, to celebrate the summer solstice at the Isles of Latium.
Each guest arrives in a different ship, and each ship takes a different amount of time to return back to the main land. You need to make sure everyone arrives at the same time.
You have been given the shipping planner, that tells you how long it takes for each ship to reach the island, in minutes, and return back (round trip time).
Each ship initially departs at the same time, and continues to do as many rounds as needed, such that each ship returns back to the main land the same time.
Your task is to determine for the given ships, what is the fewest number of minutes until each ship returns back at the same time after they leave?
Example
- Given the following input
3
5
8
Says that there are 3 different ships. The first one takes 3
minutes to complete a cycle, the
second takes 5
, and 8
minutes for last ship. After 120
minutes, all of them will return back
to Mount Othrys at the same time:
-
3
will complete exactly 40 cycles -
5
will complete exactly 24 cycles -
8
will complete exactly 15 cycles -
Given the following input
3
12
15
9
5
73
19
49
10
13
We can count that there are a total of 10 ships, and all of them will return back after
159,033,420
minutes.
How many minutes will your ships take to all return back at the same time?
Hint: The numbers might get a bit large here!
{{ if .Part1.Completed -}}
Congratulations! You got Part 1 correct. Your answer was {{ .Part1.Solution }}
.
Part 2
To continue planning for the journey, Kronos needs figure out what the total number of journeys will be for each ship, summed all together.
Example
Given the following input:
3
5
8
The total duration will still be 120
minutes before all the ships return again to the same
position. In this time, the first ship will complete 40
trips, the second ship will complete 24
trips, and the last ship will complete 15
trips, for a total of 40+24+15=79
trips.
With these new instructions, how many steps total trips will all the ships complete?
{{ if .Part2.Completed -}}
Congratulations! You have completed both parts! The answer was {{ .Part2.Solution }}
.
{{- end }} {{- end }}