AdventOfCode2022/AOC2022/Puzzles/Day2.cs

32 lines
718 B
C#

namespace AOC2022.Puzzles;
internal class Day2 : IPuzzle
{
private readonly string[] _linesFromFile;
public Day2(string[] linesFromFile)
{
_linesFromFile = linesFromFile;
}
public void FirstPuzzle()
{
int score = 0;
foreach (var line in _linesFromFile)
{
score += ((line[2] - line[0] - 1) % 3 * 3) + (line[2] - 'X' + 1);
}
Console.WriteLine($"Elf trickery knows no bounds, without the elf the score is {score}");
}
public void SecondPuzzle()
{
int score = 0;
foreach (var line in _linesFromFile)
{
score += ((line[0] - 'A' + line[2] - 'X' + 2) % 3) + 1 + (line[2] - 'X') * 3;
}
Console.WriteLine($"Elf trickery knows no bounds, with the elf help the score is {score}");
}
}