diff options
Diffstat (limited to '2025')
| -rw-r--r-- | 2025/src/day09.cpp | 29 |
1 files changed, 6 insertions, 23 deletions
diff --git a/2025/src/day09.cpp b/2025/src/day09.cpp index 796bf07..7eaf842 100644 --- a/2025/src/day09.cpp +++ b/2025/src/day09.cpp | |||
| @@ -64,31 +64,14 @@ intersects(const Segment& line, const tuple<long, long, long, long>& rect) | |||
| 64 | const auto [x1, y1] = start; | 64 | const auto [x1, y1] = start; |
| 65 | const auto [x2, y2] = end; | 65 | const auto [x2, y2] = end; |
| 66 | 66 | ||
| 67 | const auto [left, top, right, bottom] = rect; | 67 | const auto min_x = min(x1, x2); |
| 68 | 68 | const auto max_x = max(x1, x2); | |
| 69 | if ( x1 == x2 ) { | 69 | const auto min_y = min(y1, y2); |
| 70 | if ( x1 <= left || x1 >= right ) { | 70 | const auto max_y = max(y1, y2); |
| 71 | return false; | ||
| 72 | } | ||
| 73 | |||
| 74 | const auto min_y = min(y1, y2); | ||
| 75 | const auto max_y = max(y1, y2); | ||
| 76 | |||
| 77 | return max_y > top && min_y < bottom; | ||
| 78 | } | ||
| 79 | 71 | ||
| 80 | if ( y1 == y2 ) { | 72 | const auto [left, top, right, bottom] = rect; |
| 81 | if ( y1 <= top || y1 >= bottom ) { | ||
| 82 | return false; | ||
| 83 | } | ||
| 84 | |||
| 85 | auto min_x = min(x1, x2); | ||
| 86 | auto max_x = max(x1, x2); | ||
| 87 | |||
| 88 | return max_x > left && min_x < right; | ||
| 89 | } | ||
| 90 | 73 | ||
| 91 | return false; | 74 | return max_x > left && min_x < right && max_y > top && min_y < bottom; |
| 92 | } | 75 | } |
| 93 | 76 | ||
| 94 | bool | 77 | bool |
