static bool isValid_TobogganCorporate(PasswordItem passwordItem) { // N.B. The rule was redefined to mean: min = first location of letter, max = second locaiton of letter // Indexing for the password starts at 1 bool slot1ContainsLetter = (passwordItem.password[passwordItem.min - 1] == passwordItem.letter); bool slot2ContainsLetter = (passwordItem.password[passwordItem.max - 1] == passwordItem.letter); return(slot1ContainsLetter ^ slot2ContainsLetter); }
static bool isValid_SledRental(PasswordItem passwordItem) { int letterCount = passwordItem.password.Count((letter) => letter == passwordItem.letter); return((letterCount >= passwordItem.min) && (letterCount <= passwordItem.max)); }