| 123456789101112131415161718192021222324252627282930313233 |
- namespace Day19;
- public record Data(IDictionary<string, Rule> Rules, IList<Part> Parts)
- {
- public int Process()
- {
- var sum = 0;
- foreach (var part in Parts)
- {
- Console.WriteLine(part);
- var next = "in";
- while (next != "A" && next != "R")
- {
- var rule = Rules[next];
- next = rule.Apply(part);
- }
- if (next == "A")
- {
- sum += part.Total;
- Console.WriteLine("ACCEPTED");
- Console.WriteLine();
- }
- else
- {
- Console.WriteLine("REJECTED");
- Console.WriteLine();
- }
- }
- return sum;
- }
- }
|