This one was quite interesting. Integrating moving points over time is straightforward enough but how do we detect the moment a message appears? I'm going to assume it's at the point in time when the bounding box of all the points is smallest.

First we'll reuse and extend some of the geometric primitives from day 6:

data classPosition(valx:Int,valy:Int)data classVelocity(valx:Int,valy:Int)data classBox(valx:IntRange,valy:IntRange)data classPoint(valposition:Position,valvelocity:Velocity)typealiasTime=IntoperatorfunBox.plus(p:Position):Box=Box(x.extend(p.x),y.extend(p.y))funCollection<Position>.boundingBox():Box=fold(Box.EMPTY,Box::plus)

And we'll add a function to get a point's position at any time t:

We'll solve the problem by iterating over a large period of time and computing the bounding box for the points at each time. Then take the smallest of these bounding boxes:

Then we'll render the points into beautiful ASCII art at that time by building a 2D array of characters and filling in the ones at the right positions:

## re: AoC Day 10: The Stars Align VIEW POST

FULL DISCUSSIONThis one was quite interesting. Integrating moving points over time is straightforward enough but how do we detect the moment a message appears? I'm going to assume it's at the point in time when the bounding box of all the points is smallest.

First we'll reuse and extend some of the geometric primitives from day 6:

And we'll add a function to get a point's position at any time

`t`

:We'll solve the problem by iterating over a large period of time and computing the bounding box for the points at each time. Then take the smallest of these bounding boxes:

Then we'll render the points into beautiful ASCII art at that time by building a 2D array of characters and filling in the ones at the right positions:

Part 2 was either disappointing or a relief, depending on your viewpoint, as my part 1 solution already had the answer.

Full code at github.com/neilgall/adventofcode20...