protected override String DoSolve(String[] input) { List <IAuntSue> auntSues = new List <IAuntSue>(); //get the input foreach (String line in input) { auntSues.Add(Factory.CreateAuntSue(line)); } //check all aunt Sues if they match the readings IAuntSue giftingAuntSue = Factory.CreateAuntSue("Sue -1: children: 3, cats: 7, samoyeds: 2, pomeranians: 3, akitas: 0, vizslas: 0, goldfish: 5, trees: 3, cars: 2, perfumes: 1"); foreach (IAuntSue auntSue in auntSues) { int matchingParameters = auntSue.MatchingParameterCount(giftingAuntSue); if (matchingParameters >= 3) { giftingAuntSue = auntSue; break; } } return($"Aunt Sue #{giftingAuntSue.AuntSueNumber} got me the gift."); }
public int RealMatchingParameters(IAuntSue sue) { int matchFound = 0; if (Children != -1) { if (Children == sue.Children) { matchFound++; } } if (Cats != -1) { if (Cats > sue.Cats) { matchFound++; } } if (Samoyeds != -1) { if (Samoyeds == sue.Samoyeds) { matchFound++; } } if (Pomeranians != -1) { if (Pomeranians < sue.Pomeranians) { matchFound++; } } if (Akitas != -1) { if (Akitas == sue.Akitas) { matchFound++; } } if (Vizslas != -1) { if (Vizslas == sue.Vizslas) { matchFound++; } } if (Goldfish != -1) { if (Goldfish < sue.Goldfish) { matchFound++; } } if (Trees != -1) { if (Trees > sue.Trees) { matchFound++; } } if (Cars != -1) { if (Cars == sue.Cars) { matchFound++; } } if (Perfumes != -1) { if (Perfumes == sue.Perfumes) { matchFound++; } } return(matchFound); }