| 123456789101112131415161718192021222324252627 |
- using System.Text.RegularExpressions;
- namespace Day12;
- public partial class Parser
- {
- [GeneratedRegex(@".*")]
- private partial Regex LineMatch();
-
- public IEnumerable<WellRecord> Parse(string inputFile)
- {
- using var reader = File.OpenText(inputFile);
-
- while (!reader.EndOfStream)
- {
- var line = reader.ReadLine()!;
- var parts = line.Split(' ');
- yield return new WellRecord(
- parts[0],
- parts[1]
- .Split(',', StringSplitOptions.TrimEntries | StringSplitOptions.RemoveEmptyEntries)
- .Select(x => int.Parse(x))
- .ToArray()
- );
- }
- }
- }
|