Exemplo n.º 1
0
        private void SolvePart2()
        {
            logger.Information("PART 2 - Finding the final ship position and calculating the Manhattan distance, using a waypoint");

            // Initialise the ship at (0,0), and the waypoint at (10,1)
            var ship     = new Ship();
            var waypoint = new Waypoint(10, 1);

            foreach (var line in this.input)
            {
                var action = line[0];
                var value  = Int32.Parse(line.Substring(1));

                waypoint.ApplyAction(action, value, ship);
            }

            logger.Information($"The final position of the ship is ({ship.x};{ship.y}), and the Manhattan distance is {ship.GetManhattanDistance()}");
        }