bool HasAllRequired(Passport passport) { foreach (string required in requiredKeys) { if (!passport.ContainsKey(required)) { return(false); } } return(true); }
public static IEnumerable <Passport> Parse(string str) { foreach (var lines in str.GroupedLines()) { var passport = new Passport(); foreach (var line in lines) { foreach (var block in line.SpaceSeperated()) { var kvp = block.Seperate(':'); var key = kvp[0]; var value = kvp[1]; passport.duplicate = passport.ContainsKey(key); passport[key] = value; } } yield return(passport); } }