feat: solved day 3

This commit is contained in:
Stevan Freeborn
2024-12-03 23:50:01 -06:00
parent 0a7b6b2291
commit d658c31ffe
9 changed files with 225 additions and 15 deletions
+28
View File
@@ -0,0 +1,28 @@
namespace MullItOver;
public static class InstructionExtensions
{
public static int Execute(this List<Instruction> instructions)
{
var isEnabled = true;
var sum = 0;
foreach (var instruction in instructions)
{
switch (instruction)
{
case DontInstruction:
isEnabled = false;
continue;
case DoInstruction:
isEnabled = true;
continue;
case MulInstruction mul when isEnabled:
sum += mul.Execute();
continue;
}
}
return sum;
}
}