""" day 8 part 1 """ import fileinput import collections positions = collections.defaultdict(list) width = 0 height = 0 for y,row in enumerate(fileinput.input()): width = max(width, len(row.strip())) height = y + 1 for x,cell in enumerate(row.strip()): if cell != '.': positions[cell].append((x,y)) antinodes = set() for frequency, positions in positions.items(): for x1, y1 in positions: for x2, y2 in positions: if x1 != x2 or y1 != y2: nx = x1 + (x2 - x1)*2 ny = y1 + (y2 - y1)*2 if 0 <= nx < width and 0 <= ny < height: print(f'{frequency} {nx},{ny}') antinodes.add((nx, ny)) print(antinodes) print(len(antinodes))