private bool IsAuntSue(Compounds compounds) { if (compounds.Children != null && compounds.Children != auntSueCompounds.Children) { return(false); } if (compounds.Cats != null && compounds.Cats != auntSueCompounds.Cats) { return(false); } if (compounds.Samoyeds != null && compounds.Samoyeds != auntSueCompounds.Samoyeds) { return(false); } if (compounds.Pomeranians != null && compounds.Pomeranians != auntSueCompounds.Pomeranians) { return(false); } if (compounds.Akitas != null && compounds.Akitas != auntSueCompounds.Akitas) { return(false); } if (compounds.Vizslas != null && compounds.Vizslas != auntSueCompounds.Vizslas) { return(false); } if (compounds.Goldfish != null && compounds.Goldfish != auntSueCompounds.Goldfish) { return(false); } if (compounds.Trees != null && compounds.Trees != auntSueCompounds.Trees) { return(false); } if (compounds.Cars != null && compounds.Cars != auntSueCompounds.Cars) { return(false); } if (compounds.Perfumes != null && compounds.Perfumes != auntSueCompounds.Perfumes) { return(false); } return(true); }
private bool IsAuntSueWhenSomeOutputsIndicateRanges(Compounds compounds) { if (compounds.Children != null && compounds.Children != auntSueCompounds.Children) { return(false); } if (compounds.Cats != null && compounds.Cats <= auntSueCompounds.Cats) { return(false); } if (compounds.Samoyeds != null && compounds.Samoyeds != auntSueCompounds.Samoyeds) { return(false); } if (compounds.Pomeranians != null && compounds.Pomeranians >= auntSueCompounds.Pomeranians) { return(false); } if (compounds.Akitas != null && compounds.Akitas != auntSueCompounds.Akitas) { return(false); } if (compounds.Vizslas != null && compounds.Vizslas != auntSueCompounds.Vizslas) { return(false); } if (compounds.Goldfish != null && compounds.Goldfish >= auntSueCompounds.Goldfish) { return(false); } if (compounds.Trees != null && compounds.Trees <= auntSueCompounds.Trees) { return(false); } if (compounds.Cars != null && compounds.Cars != auntSueCompounds.Cars) { return(false); } if (compounds.Perfumes != null && compounds.Perfumes != auntSueCompounds.Perfumes) { return(false); } return(true); }
public Dictionary <int, Compounds> ParseInput(string input) { Dictionary <int, Compounds> compounds = new Dictionary <int, Compounds>(); string[] suesCompoundsStrings = input.Split(Environment.NewLine, StringSplitOptions.RemoveEmptyEntries); Regex sueCompoundsRegex = new Regex(@"^Sue (\d+): (\w+: \d+), (\w+: \d+), (\w+: \d+)$"); foreach (string sueCompoundsString in suesCompoundsStrings) { Match match = sueCompoundsRegex.Match(sueCompoundsString); GroupCollection groups = match.Groups; int sue = int.Parse(groups[1].Value); Compounds sueCompounds = new Compounds(); for (int i = 2; i < groups.Count; i++) { string[] compound = groups[i].Value.Split(": "); switch (compound[0]) { case "children": sueCompounds.Children = int.Parse(compound[1]); break; case "cats": sueCompounds.Cats = int.Parse(compound[1]); break; case "samoyeds": sueCompounds.Samoyeds = int.Parse(compound[1]); break; case "pomeranians": sueCompounds.Pomeranians = int.Parse(compound[1]); break; case "akitas": sueCompounds.Akitas = int.Parse(compound[1]); break; case "vizslas": sueCompounds.Vizslas = int.Parse(compound[1]); break; case "goldfish": sueCompounds.Goldfish = int.Parse(compound[1]); break; case "trees": sueCompounds.Trees = int.Parse(compound[1]); break; case "cars": sueCompounds.Cars = int.Parse(compound[1]); break; case "perfumes": sueCompounds.Perfumes = int.Parse(compound[1]); break; } } compounds.Add(sue, sueCompounds); } return(compounds); }