public void TestPartTwoValidNumber() { PasswordScanner ps = new PasswordScanner(); Assert.That(ps.IsValidPassword2(112233), Is.EqualTo(true)); Assert.That(ps.IsValidPassword2(111122), Is.EqualTo(true)); }
public void TestPartTwoInvalidNumber() { PasswordScanner ps = new PasswordScanner(); Assert.That(ps.IsValidPassword2(123444), Is.EqualTo(false)); Assert.That(ps.IsValidPassword2(124445), Is.EqualTo(false)); Assert.That(ps.IsValidPassword2(111443), Is.EqualTo(false)); Assert.That(ps.IsValidPassword2(111444), Is.EqualTo(false)); }
public string SolvePartTwo(string[] input) { string[] range = input[0].Split("-"); int validPasswords = 0; PasswordScanner ps = new PasswordScanner(); for (int i = Int32.Parse(range[0]); i <= Int32.Parse(range[1]); i++) { if (ps.IsValidPassword2(i)) { validPasswords++; } } return(validPasswords.ToString()); }