Skip to content

Commit f28d50e

Browse files
committed
day8: solved puzzle 2
1 parent c7b9c6f commit f28d50e

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed
File renamed without changes.

day8/example2.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
T....#....
2+
...T......
3+
.T....#...
4+
.........#
5+
..#.......
6+
..........
7+
...#......
8+
..........
9+
....#.....
10+
..........

day8/main.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,20 @@ func discoverAntinodes(antennaPoints map[byte][]util.Point, mapHeight int, mapWi
3838
if i == j {
3939
continue
4040
}
41+
antinodes[point] = util.Void{}
42+
antinodes[otherPoint] = util.Void{}
4143
var delta = point.Subtract(otherPoint)
44+
4245
var antinode1 = point.Add(delta)
43-
if antinode1.IsInBounds(mapHeight, mapWidth) {
46+
for antinode1.IsInBounds(mapHeight, mapWidth) {
4447
antinodes[antinode1] = util.Void{}
48+
antinode1 = antinode1.Add(delta)
4549
}
50+
4651
var antinode2 = otherPoint.Subtract(delta)
47-
if antinode2.IsInBounds(mapHeight, mapWidth) {
52+
for antinode2.IsInBounds(mapHeight, mapWidth) {
4853
antinodes[antinode2] = util.Void{}
54+
antinode2 = antinode2.Subtract(delta)
4955
}
5056
}
5157
}

0 commit comments

Comments
 (0)