hackathon/question/q02/q02.md

2.6 KiB

Saturnalia's Problem

Kronos is the father of the Olympian gods, and is the king of the Titans. He is the Titan god of Time, Justice, and Evil.

After the Olympians defeated the titans, Kronos was given a new fate: he now rules over the Isles of the Blessed and the region of Latium near the Roman Empire. Next month, the festival Saturnalia.

You've been given the task to schedule and organize the arrival of the citizens of Isles of the Blessed and Latium to reach Mount Othrys by ship.

Unfortunately, there are far too many ships to calculate this all by hand. Each ship takes a different amount of time to return back to Mount Othrys, and 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 either Isles of the Blessed or Latium, in minutes, and return back.

Each ship initially departs at the same time, and continues to do as many rounds as needed, such that each ship returns back to Mount Othrys at 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 the leave?

Example

  • Given the following input
3
5
9

Says that there are 3 different ships. The first one takes 3 minutes to complete a cycle, the second takes 5, and 9 minutes for last ship. After 45 minutes, all of them will return back to Mount Othrys at the same time.

  • Given the following input
3
12
15
9
5
73
19
49
10
13

Says 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
9

The total duration will still be 45 minutes before all the ships return again to the same position. In this time, the first ship will complete 15 trips, the second ship will complete 9 trips, and the last ship will complete 5 trips, for a total of 29 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 }}