Exemple #1
0
        object PartTwo(string input)
        {
            var origo     = new Hex(0, 0, 0);
            var locations = input.Lines()
                            .Select(s => ToHexDirections(s).Aggregate(origo, (a, d) => a.Neighbor(d)))
                            .ToArray();

            var blacks  = locations.GroupBy(h => h).Where(g => g.Count() % 2 == 1).Select(g => g.Key);
            var exhibit = new Exhibit(blacks);

            for (int i = 0; i < 100; i++)
            {
                exhibit.Next();
                Console.Out.WriteLine($"Day {exhibit.Day}: {exhibit.Blacks.Count}");
            }

            return(exhibit.Blacks.Count);
        }