| 1234567891011121314151617181920212223 |
- using System.Text.RegularExpressions;
- namespace Day21;
- public partial class Parser
- {
- [GeneratedRegex(@".*")]
- private partial Regex LineMatch();
-
- public Map Parse(string inputFile)
- {
- var lines = File.ReadAllLines(inputFile);
- var width = lines.First().Length;
- var height = lines.Length;
- return new Map(width, height, TileFactory(lines));
- }
- private IEnumerable<Tile> TileFactory(string[] lines)
- {
- return lines.SelectMany(l => l).Select(c => new Tile(c));
- }
- }
|