using System.Text.RegularExpressions; namespace Day10; public partial class Parser { [GeneratedRegex(@".*")] private partial Regex LineMatch(); public Grid Parse(string inputFile) { using var reader = File.OpenText(inputFile); var line = reader.ReadLine()!; var width = line.Length; var row = 0; var tiles = new Tile[width, width]; while (!reader.EndOfStream) { if (row != 0) { line = reader.ReadLine()!; } for (var col = 0; col < line.Length; col++) { tiles[col, row] = new Tile(line[col], new GridPoint(col, row)); } row++; } return new Grid(tiles, width, width); } }