Part 1 of day 10:
from input import asteroids import math from collections import defaultdict asteroids_coordinates = [] for row in range(0, len(asteroids)): for column in range(0,len(asteroids[row])): asteroids_coordinates.append((row, column, asteroids[row][column])) asteroid_visibility = defaultdict(set) for asteroid_1 in asteroids_coordinates: for asteroid_2 in asteroids_coordinates: if asteroid_1 == asteroid_2: continue if asteroid_1[2] == "#" and asteroid_2[2] == "#": angle = math.atan2(asteroid_2[0] - asteroid_1[0], asteroid_2[1] - asteroid_1[1]) % (2 * math.pi) asteroid_visibility[asteroid_1].add(angle) solution = len(max(asteroid_visibility.values(), key=len)) print(solution)
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Part 1 of day 10: