| 123456789101112131415161718192021222324252627282930 |
- using System.Text.RegularExpressions;
- namespace Day23;
- public partial class Parser
- {
- [GeneratedRegex(@".*")]
- private partial Regex LineMatch();
-
- public Map Parse(string inputFile)
- {
- var lines = File.ReadAllLines(inputFile);
- var width = lines[0].Length;
- var height = lines.Length;
- var tiles = new Tile[width, height];
- var row = 0;
- foreach (var line in lines)
- {
- for (var col = 0; col < width; col++)
- {
- tiles[col, row] = new Tile(line[col], new Vec(col, row));
- }
- row++;
- }
- return new Map(tiles);
- }
- }
|