Refactor Day09 to rename RectangleOverlapsBorder to RectangleCrossesBorder for method clarity
This commit is contained in:
parent
927810fb0c
commit
3360b6cfba
|
|
@ -64,7 +64,7 @@ public class Day09 : IPuzzleSolver<long>
|
||||||
|
|
||||||
private bool IsRectangleInsideBorders(CoordinatePair[] borders, CoordinatePair rectangle)
|
private bool IsRectangleInsideBorders(CoordinatePair[] borders, CoordinatePair rectangle)
|
||||||
{
|
{
|
||||||
return !borders.Any(border => RectangleOverlapsBorder(rectangle, border));
|
return !borders.Any(border => RectangleCrossesBorder(rectangle, border));
|
||||||
}
|
}
|
||||||
|
|
||||||
private CoordinatePair AsMinMax(Coordinate a, Coordinate b)
|
private CoordinatePair AsMinMax(Coordinate a, Coordinate b)
|
||||||
|
|
@ -72,7 +72,7 @@ public class Day09 : IPuzzleSolver<long>
|
||||||
return (Math.Min(a.x, b.x), Math.Min(a.y, b.y), Math.Max(a.x, b.x), Math.Max(a.y, b.y));
|
return (Math.Min(a.x, b.x), Math.Min(a.y, b.y), Math.Max(a.x, b.x), Math.Max(a.y, b.y));
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool RectangleOverlapsBorder(CoordinatePair rectangle, CoordinatePair borderSegment)
|
private bool RectangleCrossesBorder(CoordinatePair rectangle, CoordinatePair borderSegment)
|
||||||
{
|
{
|
||||||
return rectangle.minX < borderSegment.maxX && rectangle.minY < borderSegment.maxY &&
|
return rectangle.minX < borderSegment.maxX && rectangle.minY < borderSegment.maxY &&
|
||||||
rectangle.maxX > borderSegment.minX && rectangle.maxY > borderSegment.minY;
|
rectangle.maxX > borderSegment.minX && rectangle.maxY > borderSegment.minY;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue