| 123456789101112131415161718192021222324252627282930313233 |
- using System.Text.RegularExpressions;
- using Day10;
- namespace Day11;
- public partial class Parser
- {
- [GeneratedRegex(@".*")]
- private partial Regex LineMatch();
-
- public Universe Parse(string inputFile)
- {
- using var reader = File.OpenText(inputFile);
- var universe = new Universe();
- var row = 0;
- while (!reader.EndOfStream)
- {
- var line = reader.ReadLine()!;
- for (var col = 0; col < line.Length; col++)
- {
- if (line[col] == '#')
- {
- universe.Add(new Galaxy(new GridPoint(col, row)));
- }
- }
- row++;
- }
- return universe;
- }
- }
|