Exemplo n.º 1
0
        static void Main(string[] args)
        {
            try {
                string input = @"C:\Users\jpowell\source\repos\AdventOfCode2017\AdventOfCode12-1\Input.txt";
                ReadInput(input);

                Villager villagerZero = MyVillagers.First(x => x.idNumber == 0);


                foreach (Villager villager in MyVillagers)
                {
                    villager.GetConnections(MyVillagers);
                }

                Console.WriteLine("Size of Villager 0 group: " + villagerZero.GetGroup().Count.ToString());

                int groupCount = 0;
                while (MyVillagers.Any())
                {
                    groupCount++;
                    Villager currentVillager = MyVillagers.First();
                    foreach (Villager groupedVillager in currentVillager.GetGroup())
                    {
                        MyVillagers.Remove(groupedVillager);
                    }
                }

                Console.WriteLine("Total number of groups: " + groupCount.ToString());
            }
            catch (Exception ex) {
                Console.WriteLine(ex.Message);
            }
            finally {
                Console.ReadKey();
            }
        }