string[] input = File.ReadAllLines(@"C:\Users\*\Advent of Code\2023\Day16\Day16Input.txt");
string[] test = File.ReadAllLines(@"C:\Users\*\Advent of Code\2023\Day16\Day16Test.txt");
Console.WriteLine("Part One: " + Solver(input));
int Solver(string[] input)
Dictionary<Coordinates, char> grid = new();
List<Coordinates> litCoordinates = new();
List<State> seen = new();
Coordinates start = new(0, 0);
string direction = "EAST";
litCoordinates.Add(start);
int maxRow = input.Length;
int maxCol = input[0].Length;
for (int row = 0; row < input.Length; row++)
for (int col = 0; col < input[0].Length; col++)
grid[new Coordinates(col, row)] = input[row][col];
Queue<State> lightBranches = new();
lightBranches.Enqueue(new State(direction, litCoordinates[0]));
while (lightBranches.TryDequeue(out State prevSpace))
if (seen.Contains(prevSpace)) continue;
(direction, start) = prevSpace;
Coordinates nextSpace = NestSpace(direction, start);
if (nextSpace.Row < 0 || nextSpace.Column < 0 || nextSpace.Row >= maxRow || nextSpace.Column >= maxCol)
if (!litCoordinates.Contains(nextSpace)) litCoordinates.Add(nextSpace);
if (direction == "EAST" || direction == "WEST")
lightBranches.Enqueue(new State("NORTH", nextSpace));
lightBranches.Enqueue(new State("SOUTH", nextSpace));
else lightBranches.Enqueue(new State(direction, nextSpace));
if (direction == "NORTH" || direction == "SOUTH")
lightBranches.Enqueue(new State("EAST", nextSpace));
lightBranches.Enqueue(new State("WEST", nextSpace));
else lightBranches.Enqueue(new State(direction, nextSpace));
if (direction == "NORTH")
else if (direction == "EAST")
else if (direction == "WEST")
else if (direction == "SOUTH")
lightBranches.Enqueue(new State(direction, nextSpace));
if (direction == "NORTH")
else if (direction == "EAST")
else if (direction == "WEST")
else if (direction == "SOUTH")
lightBranches.Enqueue(new State(direction, nextSpace));
lightBranches.Enqueue(new State(direction, nextSpace));
for (int row = 0; row < input.Length; row++)
for (int col = 0; col < input[0].Length; col++)
if (litCoordinates.Contains(new Coordinates(col, row)))
Console.WriteLine("Row {0} \t Contains {1}", row, rowcount);
return litCoordinates.Count;
Coordinates NestSpace(string direction, Coordinates start)
return new Coordinates(col, row);
record Coordinates(int Column, int Row);
record State(string Direction, Coordinates Coordinates);