Skip to content

Commit

Permalink
[2019/10] p2 solved
Browse files Browse the repository at this point in the history
  • Loading branch information
StarlitGhost committed Dec 26, 2023
1 parent 8274e61 commit e73b11d
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
Binary file modified .aoc_tiles/tiles/2019/10.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 23 additions & 2 deletions 2019/10/script.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ def main():
asteroids = list(grid.find_all('#'))

most_seen = 0
best_asteroid = None
best_angles = {}
for asteroid in asteroids:
angles = defaultdict(list)
for other in asteroids:
Expand All @@ -21,8 +23,27 @@ def main():

if len(angles) > most_seen:
most_seen = len(angles)

print('p1:', most_seen)
best_asteroid = asteroid
best_angles = angles

print('p1:', most_seen, best_asteroid)

angles = sorted(best_angles.keys())
vaporised = 0
last_vaporised = None
empty = []
while vaporised != 200:
for angle in angles:
if best_angles[angle]:
last_vaporised = Vec2(best_angles[angle].pop(0))
vaporised += 1
if vaporised == 200:
break
if not best_angles[angle]:
empty.append(angle)
for angle in empty:
del best_angles[angle]
print('p2:', last_vaporised.x * 100 + last_vaporised.y, last_vaporised)


if __name__ == "__main__":
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ My solutions to the yearly Advents of Code
<img src=".aoc_tiles/tiles/2022/15.png" width="161px">
</a>
<h1 align="center">
2019 - 19
2019 - 20
</h1>
<a href="2019/1/script.py">
<img src=".aoc_tiles/tiles/2019/01.png" width="161px">
Expand Down

0 comments on commit e73b11d

Please sign in to comment.