Parser.cs 532 B

123456789101112131415161718192021
  1. using System.Text.RegularExpressions;
  2. namespace Day9;
  3. public partial class Parser
  4. {
  5. [GeneratedRegex(@".*")]
  6. private partial Regex LineMatch();
  7. public IEnumerable<Sequence> Parse(string inputFile)
  8. {
  9. using var reader = File.OpenText(inputFile);
  10. while (!reader.EndOfStream)
  11. {
  12. var line = reader.ReadLine()!;
  13. var numbers = line.Split(' ').Select(long.Parse).ToArray();
  14. yield return new Sequence(numbers);
  15. }
  16. }
  17. }