public Result Aggregate(PasswordEntry entry) { return(new Result { ValidV1 = ValidV1 + (entry.IsValid ? 1 : 0), ValidV2 = ValidV2 + (entry.IsValidV2 ? 1 : 0) }); }
static void Main(string[] args) { using (var reader = File.OpenText("input.txt")) { var result = Lines(reader).Select(l => PasswordEntry.Parse(l)).Aggregate(new Result(), (previous, entry) => previous.Aggregate(entry)); Console.WriteLine($"Valid (v1): {result.ValidV1}"); Console.WriteLine($"Valid (v2): {result.ValidV2}"); } }