day 10
the stars align
approach
each point's position at time t is computed directly from its start and velocity, x + vx·t, with no stepping. area gives the bounding box of all points at a given time.
min_area tries t = 0, 1, 2, … and stops as soon as the box starts growing again, printing the time just before (the part 2 answer). print_grid draws the points at that time with #, and the message (part 1) is read off the drawing.
the trick
the message appears when the points are packed closest, so the moment the bounding box stops shrinking is the moment to look.
python
def min_area():
t=0
curr=area(start_position)
prev=curr+1
for i in range(100000):
prev=curr
curr=area(grid(i))
if curr>prev:
print(i-1)
break