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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
--- Part Two ---
Once you give them the coordinates, the Elves quickly deploy an Instant Monitoring Station to the
location and discover the worst: there are simply too many asteroids.
The only solution is [1m[97mcomplete vaporization by giant laser[0m.
Fortunately, in addition to an asteroid scanner, the new monitoring station also comes equipped with
a giant rotating laser perfect for vaporizing asteroids. The laser starts by pointing
[1m[97mup[0m and always rotates [1m[97mclockwise[0m, vaporizing any asteroid it hits.
If multiple asteroids are [1m[97mexactly[0m in line with the station, the laser only has enough power to
vaporize [1m[97mone[0m of them before continuing its rotation. In other words, the same asteroids that can be
[1m[97mdetected[0m can be vaporized, but if vaporizing one asteroid makes another one detectable, the
newly-detected asteroid won't be vaporized until the laser has returned to the same position by
rotating a full 360 degrees.
For example, consider the following map, where the asteroid with the new monitoring station (and
laser) is marked X:
.#....#####...#..
##...##.#####..##
##...#...#.#####.
..#.....X...###..
..#.#.....#....##
The first nine asteroids to get vaporized, in order, would be:
.#....###[1m[97m2[0m[1m[97m4[0m...#..
##...##.[1m[97m1[0m[1m[97m3[0m#[1m[97m6[0m[1m[97m7[0m..[1m[97m9[0m#
##...#...[1m[97m5[0m.[1m[97m8[0m####.
..#.....X...###..
..#.#.....#....##
Note that some asteroids (the ones behind the asteroids marked 1, 5, and 7) won't have a chance to
be vaporized until the next full rotation. The laser continues rotating; the next nine to be
vaporized are:
.#....###.....#..
##...##...#.....#
##...#......[1m[97m1[0m[1m[97m2[0m[1m[97m3[0m[1m[97m4[0m.
..#.....X...[1m[97m5[0m##..
..#.[1m[97m9[0m.....[1m[97m8[0m....[1m[97m7[0m[1m[97m6[0m
The next nine to be vaporized are then:
.[1m[97m8[0m....###.....#..
[1m[97m5[0m[1m[97m6[0m...[1m[97m9[0m#...#.....#
[1m[97m3[0m[1m[97m4[0m...[1m[97m7[0m...........
..[1m[97m2[0m.....X....##..
..[1m[97m1[0m..............
Finally, the laser completes its first full rotation (1 through 3), a second rotation (4 through 8),
and vaporizes the last asteroid (9) partway through its third rotation:
......[1m[97m2[0m[1m[97m3[0m[1m[97m4[0m.....[1m[97m6[0m..
......[1m[97m1[0m...[1m[97m5[0m.....[1m[97m7[0m
.................
........X....[1m[97m8[0m[1m[97m9[0m..
.................
In the large example above (the one with the best monitoring station location at 11,13):
- The 1st asteroid to be vaporized is at 11,12.
- The 2nd asteroid to be vaporized is at 12,1.
- The 3rd asteroid to be vaporized is at 12,2.
- The 10th asteroid to be vaporized is at 12,8.
- The 20th asteroid to be vaporized is at 16,0.
- The 50th asteroid to be vaporized is at 16,9.
- The 100th asteroid to be vaporized is at 10,16.
- The 199th asteroid to be vaporized is at 9,6.
- [1m[97mThe 200th asteroid to be vaporized is at 8,2.[0m
- The 201st asteroid to be vaporized is at 10,9.
- The 299th and final asteroid to be vaporized is at 11,1.
The Elves are placing bets on which will be the [1m[97m200th[0m asteroid to be vaporized. Win the bet by
determining which asteroid that will be; [1m[97mwhat do you get if you multiply its X coordinate by 100 and
then add its Y coordinate?[0m (For example, 8,2 becomes [1m[97m802[0m.)
|