Пример #1
0
        static void Main(string[] args)
        {
            /*
             *  Gonna have to probably use a coordinate system and store visited houses in a seperate container.
             *  Should be able to use a key search to check for originals and then grab the size at the end.
             *  Could make a Santa object and update his position based on the input, then grab current position and store it.
             */

            //CoordsComparer coordComp = new CoordsComparer();

            // Containers
            HashSet <String> visitedList = new HashSet <String>();

            // Grab input
            StreamReader sr    = new StreamReader(@"C:\Users\cordell.wagendorf\Documents\GitHubVisualStudio\Advent-of-Code\Day 3\Day 3\input");
            String       input = sr.ReadLine();

            // Close file
            sr.Close();

            // Create an instance of Santa and Robo-Santa
            Santa santa     = new Santa();
            Santa roboSanta = new Santa();

            // Push origin position to stack
            visitedList.Add(santa.getPosition().toString());

            // Current chars from input
            char[] directions = input.ToCharArray();

            // Run through directions
            for (int i = 0; i < directions.Length; i++)
            {
                // Current santa
                Santa current;

                // Update Santas, santa even, robo odd
                if ((i % 2) == 0)
                {
                    current = santa;
                }
                else
                {
                    current = roboSanta;
                }

                current.move(directions[i]);

                // Grab position
                Coords temp = current.getPosition();

                Console.WriteLine(temp.getX() + ", " + temp.getY());

                // Add into hashset
                visitedList.Add(temp.toString());

                //Console.WriteLine("Count: " + visitedList.Count());

                // Pause
                //Thread.Sleep(1000);
            }

            Console.WriteLine("Visisted {0} unique houses", visitedList.Count());

            Console.ReadLine();
        }