Пример #1
0
        public string Run(Aoc.Framework.Part part)
        {
            if (part == Aoc.Framework.Part.Part1)
            {
                var counts = _ids.Select(id => HasDuplicatesOrTriplicates(id));
                return((counts.Count(c => c.Item1) * counts.Count(c => c.Item2)).ToString());
            }

            if (part == Aoc.Framework.Part.Part2)
            {
                foreach (string id1 in _ids)
                {
                    string id2 = _ids.Where(s => Difference.Count(id1, s) == 1).FirstOrDefault();
                    if (id2 != null)
                    {
                        return(Difference.GetCommonPart(id1, id2));
                    }
                }
            }

            return("");
        }