hackathon/question/q03/q03.md

86 lines
2.2 KiB
Markdown

2022-04-28 23:31:09 +07:00
As June approaches and summer sports rise in popularity, people are becoming more festive, and want
to celebrate.
You are participating the start of the Dragon Boat Festival, where you will be competing to collect
as many coins as possible within 3 hours. As part of the competition, you have been provided the
number of coins in each section of the lake.
As part of your team strategy, you want to first calculate the total number of coins that can be
collected.
Your map is sectioned into a grid, where each digit represents the number of coins in that area.
### Example
- Given the following input
```
46327
85390
29543
```
Shows that there are a total of `5 * 3 = 15` sections within the lake.
Adding up all of the individual digits, we see that the total number of coins within this lake
is `70`.
**What is the total number of coins within the lake?**
{{ if .Part1.Completed -}}
**Congratulations! You got Part 1 correct. Your answer was `{{ .Part1.Solution }}`.**
## Part 2
You recently learned there there is going to be some serious competition within the Dragon Boat
Festival. Nevertheless, you are still determined to win. You have developed a new strategy in order
to collect coins as efficiently as possible.
As part of this secret strategy, which produces the dragon number, you will need to calculate two
values:
1. The maximum sum of coins in any given column
2. The maximum sum of coins in any given row
Your final answer is the product of these two sums.
### Example
- Given the following input
```
46327
85390
29543
```
In this example, there are 3 rows, and 5 columns.
1. Sum of row 1: `4+6+3+2+7 = 22`
2. Sum of row 2: `8+5+3+9+0 = 25`
3. Sum of row 2: `2+9+5+4+3 = 23`
**The maximum sum from rows 1-3 is 25**
1. Sum of column 1: `4+8+2 = 14`
2. Sum of column 2: `6+5+9 = 20`
3. Sum of column 3: `3+3+5 = 11`
4. Sum of column 4: `2+9+4 = 15`
5. Sum of column 5: `7+0+3 = 10`
**The maximum sum from columns 1-5 is 20**
Using this information, the maximums of the rows and columns is `25` ad `20`.
The answer, and the dragon number, is `25*20 = 500`.
**What is the dragon number for your lake?**
{{ if .Part2.Completed -}}
**Congratulations! You have completed both parts! The answer was `{{ .Part2.Solution }}`.**
{{- end }}
{{- end }}