finish day 3

master
cyberdick 2022-12-03 19:22:08 +05:30
parent ac197c4d2b
commit bd14f76482
1 changed files with 18 additions and 1 deletions

View File

@ -51,7 +51,24 @@ internal class Day3 : IPuzzle
public void SecondPuzzle()
{
throw new NotImplementedException();
var prioritySum = 0;
for (int i = 0; i < noOfRuckSacks; i += 3)
{
var elf1Sack = _linesFromFile[i].Trim();
var elf2Sack = _linesFromFile[i + 1].Trim();
var elf3Sack = _linesFromFile[i + 2].Trim();
char authenticItem = ' ';
foreach (var item in elf1Sack)
{
if (elf2Sack.Contains(item) && elf3Sack.Contains(item))
{
authenticItem = item;
break;
}
}
prioritySum += EvaluatePriority(authenticItem);
}
Console.WriteLine(prioritySum.ToString());
}
private static int EvaluatePriority(char ruckSackItem)