1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
--- Day 24: Planet of Discord ---
You land on Eris, your last stop before reaching Santa. As soon as you do, your sensors start
picking up strange life forms moving around: Eris is infested with bugs! With an over 24-hour
roundtrip for messages between you and Earth, you'll have to deal with this problem on your own.
Eris isn't a very large place; a scan of the entire area fits into a 5x5 grid (your puzzle input).
The scan shows [1m[97mbugs[0m (#) and [1m[97mempty spaces[0m (.).
Each [1m[97mminute[0m, The bugs live and die based on the number of bugs in the [1m[97mfour adjacent tiles[0m:
- A bug [1m[97mdies[0m (becoming an empty space) unless there is [1m[97mexactly one[0m bug adjacent to it.
- An empty space [1m[97mbecomes infested[0m with a bug if [1m[97mexactly one or two[0m bugs are adjacent to it.
Otherwise, a bug or empty space remains the same. (Tiles on the edges of the grid have fewer than
four adjacent tiles; the missing tiles count as empty space.) This process happens in every location
[1m[97msimultaneously[0m; that is, within the same minute, the number of adjacent bugs is counted for every
tile first, and then the tiles are updated.
Here are the first few minutes of an example scenario:
Initial state:
....#
#..#.
#..##
..#..
#....
After 1 minute:
#..#.
####.
###.#
##.##
.##..
After 2 minutes:
#####
....#
....#
...#.
#.###
After 3 minutes:
#....
####.
...##
#.##.
.##.#
After 4 minutes:
####.
....#
##..#
.....
##...
To understand the nature of the bugs, watch for the first time a layout of bugs and empty spaces
[1m[97mmatches any previous layout[0m. In the example above, the first layout to appear twice is:
.....
.....
.....
#....
.#...
To calculate the [1m[97mbiodiversity rating[0m for this layout, consider each tile left-to-right in the top
row, then left-to-right in the second row, and so on. Each of these tiles is worth biodiversity
points equal to [1m[97mincreasing powers of two[0m: 1, 2, 4, 8, 16, 32, and so on. Add up the biodiversity
points for tiles with bugs; in this example, the 16th tile (32768 points) and 22nd tile (2097152
points) have bugs, a total biodiversity rating of [1m[97m2129920[0m.
[1m[97mWhat is the biodiversity rating for the first layout that appears twice?[0m
|