AdventOfCode/AdventOfCode.Solutions/2023/Day 14/Day14.cs
2023-12-14 16:57:40 +01:00

45 lines
1.3 KiB
C#

using AdventOfCode.Core;
namespace AdventOfCode.Solutions._2023
{
public class Day14(InputReader reader) : IChallange
{
private InputReader _inputReader = reader;
public async Task<string> GetSolutionPart1()
{
string[] lines = await _inputReader.ReadAsVerticalArrayString();
int totalWeight = 0;
for(int lineIndex = 0; lineIndex < lines.Length; lineIndex++)
{
int weight = lines[lineIndex].Length, lineWeight = 0;
for (int charIndex = 0; charIndex < lines[lineIndex].Length; charIndex++)
{
if (lines[lineIndex][charIndex] is '.')
continue;
if (lines[lineIndex][charIndex] is '#')
{
weight = lines[lineIndex].Length - charIndex - 1;
continue;
}
if (lines[lineIndex][charIndex] is 'O')
{
lineWeight += weight;
weight--;
}
}
totalWeight += lineWeight;
}
return totalWeight.ToString();
}
public async Task<string> GetSolutionPart2()
{
return string.Empty;
}
}
}