static async Task Main(string[] args) { var policies = (await File.ReadAllLinesAsync("input.txt")).Select(x => PasswordPolicy.Parse(x)); Console.WriteLine(policies.Count(x => x.CheckPasswordPart1())); Console.WriteLine(policies.Count(x => x.CheckPasswordPart2())); }
public string Solve() { var inputs = Inputs.GetInputsValues("2"); var lines = inputs.Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); var count = 0; foreach (var line in lines) { if (PasswordPolicy.ValidateOne(PasswordPolicy.Parse(line))) { count++; } } return(count.ToString()); }