namespace Day18; public class CellData { public Vec TopLeft { get; } public Vec BottomRight { get; } public List? Lines { get; set; } public bool HasCrossing { get; private set; } public CellData(Vec tl, Vec br) { TopLeft = tl; BottomRight = br; } public long Size() { return (BottomRight.X - TopLeft.X) * (BottomRight.Y - TopLeft.Y); } public void Calculate() { foreach (var l in Lines!) { if (l.Dir.IsVertical && l.Start.X == TopLeft.X) { var start = Math.Min(l.Start.Y, l.Start.Y + l.Length * l.Dir.Y); var end = Math.Max(l.Start.Y, l.Start.Y + l.Length * l.Dir.Y); if (start <= TopLeft.Y && end >= TopLeft.Y && start <= BottomRight.Y && end >= BottomRight.Y) { HasCrossing = true; break; } } } } }