hackathon/question/q04/q04.md

108 lines
2.1 KiB
Markdown

2022-04-29 06:56:26 +07:00
You decide to visit the archipelagos of Indonesia. You find a map of the area near South Sulawesi,
and can see where there is land (marked with an `X`), and where the ocean is (empty space).
You and your friends decide you want to stay at the islands for the weekend.
However, there are so many islands to pick from, and you have no way to decide which one to pick to
stay at. To make a decision, you come up with a plan.
Firstly, you have decided that the location needs to be a peninsula. That means, water on 3 sides,
and land on one side.
### Note:
> When counting peninsulas, do not consider diagonal tiles. Only consider those directly to the left,
> right, above and below the tile.
> The (invisible) edges of the input all count after the water tiles.
### Example
Given the following input:
```
ABCDE
1. X XX
2. X X
3. X
4. XX X
```
Contains 4 peninsulas:
* 1D
* 3D
* 4A
* 4B
---
Given the following input:
```
ABCDEFGH
1 XXX XX
2 X XX X
3 XXXXX X
4 X X
5 X XXXX
6 XX XXXX
```
Contains 9 peninsulas:
* 1C
* 1H
* 2B
* 3A
* 4D
* 5A
* 5H
* 6B
* 6D
To get the answer for part one, **what is the total number of peninsulas you can count on your
map?**
{{ if .Part1.Completed -}}
**Congratulations! You got Part 1 correct. Your answer was `{{ .Part1.Solution }}`.**
## Part 2
With the number of peninsulas that are in the lake, you are having trouble determining which one to
pick. In order to do so, you have devised a plan to try to see which island has the most number of
peninsulas.
In order to do this, though, we first need to count how many islands we have.
An island is a contiguous set of grids, that are connected by water in at least one of the four
directions, similar to a peninsula.
### Example
Given the following input:
```
ABCDEFGH
1 XXX XX
2 X XX X
3 XXXXX X
4 X X
5 X XXXX
6 XX XXXX
```
There are 3 distinct islands.
**What is the total number of islands in your map?**
{{ if .Part2.Completed -}}
**Congratulations! You have completed both parts! The answer was `{{ .Part2.Solution }}`.**
{{- end }}
{{- end }}