finish day 3
parent
ac197c4d2b
commit
bd14f76482
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue