25 lines
657 B
C#
25 lines
657 B
C#
namespace AOC2022.Puzzles;
|
|
|
|
internal class Day2 : IPuzzle
|
|
{
|
|
private readonly string[] _linesFromFile;
|
|
|
|
public Day2(string[] linesFromFile)
|
|
{
|
|
_linesFromFile = linesFromFile;
|
|
}
|
|
|
|
public void SolveFirstPuzzle()
|
|
{
|
|
var score = _linesFromFile.Sum(line => (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 SolveSecondPuzzle()
|
|
{
|
|
var score = _linesFromFile.Sum(line => (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}");
|
|
}
|
|
} |