diff options
author | Botond Hende <nettingman@gmail.com> | 2024-12-11 10:18:23 +0100 |
---|---|---|
committer | Botond Hende <nettingman@gmail.com> | 2024-12-11 10:18:23 +0100 |
commit | 0a5c1f77d01fc0bd166494787f24562e2fd3a9e9 (patch) | |
tree | 99b0d38ef86653b6ff4aae26381ebdf0895f829d /2024/day8/solve2.py | |
parent | cbf5c348db4a693b15e455a23e07072587edf4b0 (diff) |
renamed day folders to two digit format
Diffstat (limited to '2024/day8/solve2.py')
-rw-r--r-- | 2024/day8/solve2.py | 35 |
1 files changed, 0 insertions, 35 deletions
diff --git a/2024/day8/solve2.py b/2024/day8/solve2.py deleted file mode 100644 index 1642e35..0000000 --- a/2024/day8/solve2.py +++ /dev/null @@ -1,35 +0,0 @@ -lines = [] - -with open("input") as f: - for line in f: - lines.append(line.strip()) - -antennas: dict[str, list[tuple[int, int]]] = {} -for row_idx, line in enumerate(lines): - for col_idx, char in enumerate(line): - if char != ".": - if char not in antennas: - antennas[char] = [] - - antennas[char].append((row_idx, col_idx)) - -row_count = len(lines) -col_count = len(lines[0]) -antinodes: set[tuple[int, int]] = set() -for antenna_list in antennas.values(): - for idx, antenna1 in enumerate(antenna_list): - for antenna2 in antenna_list[idx + 1:]: - row_diff = antenna2[0] - antenna1[0] - col_diff = antenna2[1] - antenna1[1] - - pos = antenna1 - while 0 <= pos[0] < row_count and 0 <= pos[1] < col_count: - antinodes.add(pos) - pos = (pos[0] - row_diff, pos[1] - col_diff) - - pos = antenna2 - while 0 <= pos[0] < row_count and 0 <= pos[1] < col_count: - antinodes.add(pos) - pos = (pos[0] + row_diff, pos[1] + col_diff) - -print(len(antinodes))
\ No newline at end of file |