Mercurial > repos > other > adventofcode2023
view day24.txt @ 34:59620bbc4084
Implement day 24 - 2D intersection
Needs an offset because the numbers are big enough to overflow
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Fri, 05 Jan 2024 11:42:13 +0000 |
parents | |
children | ca54f9702892 |
line wrap: on
line source
--- Day 24: Never Tell Me The Odds --- A set of objects have positions and velocities in 3D space, noted as `x, y, z @ Δx, Δy, Δz`, e.g. 19, 13, 30 @ -2, 1, -2 18, 19, 22 @ -1, -1, -2 20, 25, 34 @ -2, -2, -4 12, 31, 28 @ -1, -2, -1 20, 19, 15 @ 1, -5, -3 Ignoring the Z axis, which objects will intersect _in future_ within a given bounding box. For example, with the box 7,7 to 27,27 and the objects above: Object A: 19, 13, 30 @ -2, 1, -2 Object B: 18, 19, 22 @ -1, -1, -2 Objects' paths will cross inside the test area (at x=14.333, y=15.333). Object A: 19, 13, 30 @ -2, 1, -2 Object B: 20, 25, 34 @ -2, -2, -4 Objects' paths will cross inside the test area (at x=11.667, y=16.667). Object A: 19, 13, 30 @ -2, 1, -2 Object B: 12, 31, 28 @ -1, -2, -1 Objects' paths will cross outside the test area (at x=6.2, y=19.4). Object A: 19, 13, 30 @ -2, 1, -2 Object B: 20, 19, 15 @ 1, -5, -3 Objects' paths crossed in the past for Object A. Object A: 18, 19, 22 @ -1, -1, -2 Object B: 20, 25, 34 @ -2, -2, -4 Objects' paths are parallel; they never intersect. Object A: 18, 19, 22 @ -1, -1, -2 Object B: 12, 31, 28 @ -1, -2, -1 Objects' paths will cross outside the test area (at x=-6, y=-5). Object A: 18, 19, 22 @ -1, -1, -2 Object B: 20, 19, 15 @ 1, -5, -3 Objects' paths crossed in the past for both Objects. Object A: 20, 25, 34 @ -2, -2, -4 Object B: 12, 31, 28 @ -1, -2, -1 Objects' paths will cross outside the test area (at x=-2, y=3). Object A: 20, 25, 34 @ -2, -2, -4 Object B: 20, 19, 15 @ 1, -5, -3 Objects' paths crossed in the past for Object B. Object A: 12, 31, 28 @ -1, -2, -1 Object B: 20, 19, 15 @ 1, -5, -3 Objects' paths crossed in the past for both Objects. Look for future intersections that happen with an X and Y position each at least 200000000000000 and at most 400000000000000. Disregard the Z axis entirely. Note: Some objects are moving upwards.