diff options
Diffstat (limited to 'src/2022/day15/aoc.h')
-rw-r--r-- | src/2022/day15/aoc.h | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/src/2022/day15/aoc.h b/src/2022/day15/aoc.h index ffb4183..eaed197 100644 --- a/src/2022/day15/aoc.h +++ b/src/2022/day15/aoc.h @@ -19,8 +19,9 @@ struct sensor { } }; - struct triangle { - pos as[3]; + struct line { + pos p0; + pos p1; }; static int minx; @@ -57,6 +58,16 @@ struct sensor { return d2 <= d1 && !(p == ps[1]); } + line line_by_dy(int dy) { + int d = mdistance(ps[0], ps[1]); + int y = ps[0].y + dy; + int dx = d - std::abs(dy); + int x = ps[0].x - dx; + pos p0 = {x, y}; + pos p1 = {x + 2 * dx, y}; + return {p0 , p1}; + } + sensor(line_view lv) { const char* p = lv.line; int *is[] = {&ps[0].x, &ps[0].y, &ps[1].x, &ps[1].y}; |