Skip to content

Commit 77d6295

Browse files
committed
Remove debug logging and dead code from day 8
1 parent 9e8fcfa commit 77d6295

File tree

1 file changed

+2
-33
lines changed

1 file changed

+2
-33
lines changed

day08/src/day08.php

Lines changed: 2 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,6 @@ function __construct(int $x = 0, int $y = 0) {
99
$this->y = $y;
1010
}
1111

12-
static function parse(string $raw): Vec2 {
13-
$split = explode(",", $raw);
14-
return new Vec2(intval($split[0]), intval($split[1]));
15-
}
16-
1712
function __toString(): string {
1813
return "$this->x,$this->y";
1914
}
@@ -50,18 +45,6 @@ function findFrequencyLocations(array $matrix, int $width, int $height): array {
5045
return $freqLocs;
5146
}
5247

53-
function findAntennas(array $freqLocs, int $width, int $height): array {
54-
$antennas = [];
55-
56-
foreach ($freqLocs as $freq => $locs) {
57-
foreach ($locs as $loc) {
58-
$antennas["$loc"] = true;
59-
}
60-
}
61-
62-
return $antennas;
63-
}
64-
6548
function findAntinodes(array $freqLocs, int $width, int $height, bool $includeStart = true, int $maxRepeats = PHP_INT_MAX): array {
6649
$antinodes = [];
6750

@@ -102,23 +85,9 @@ function findAntinodes(array $freqLocs, int $width, int $height, bool $includeSt
10285
$width = strlen($matrix[0]);
10386

10487
$freqLocs = findFrequencyLocations($matrix, $width, $height);
105-
$antennas = findAntennas($freqLocs, $width, $height);
106-
107-
$antinodes1 = findAntinodes($freqLocs, $width, $height, false, 1);
108-
$antinodes2 = findAntinodes($freqLocs, $width, $height);
109-
110-
// Draw the antinode pattern for fun and profit
111-
foreach (array_keys($antinodes2) as $rawAntinode) {
112-
$antinode = Vec2::parse($rawAntinode);
113-
$matrix[$antinode->y][$antinode->x] = '#';
114-
}
115-
116-
foreach ($matrix as $line) {
117-
echo "$line" . PHP_EOL;
118-
}
11988

120-
$part1 = count($antinodes1);
89+
$part1 = count(findAntinodes($freqLocs, $width, $height, false, 1));
12190
echo "Part 1: $part1" . PHP_EOL;
12291

123-
$part2 = count($antinodes2);
92+
$part2 = count(findAntinodes($freqLocs, $width, $height));
12493
echo "Part 2: $part2" . PHP_EOL;

0 commit comments

Comments
 (0)