Exemplo n.º 1
0
        private static void TestRightRotation(int startAngle, int rotationRight, int expected)
        {
            var debugPos = new ShipPosition();

            debugPos.MakeMove('L', startAngle);
            debugPos.MakeMove('R', rotationRight);

            var msg = expected == debugPos.Angle ? string.Empty : "FAIL -> ";

            Console.WriteLine($"{msg}Expected: {expected}; Actual: {debugPos.Angle}");
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            const string filename = "input.txt";

            var position = new ShipPosition();

            using var sr = new StreamReader(filename);
            string line;

            while ((line = sr.ReadLine()) != null)
            {
                var command = line[0];
                var value   = int.Parse(line.Substring(1));
                position.MakeMove(command, value);
            }
            Console.WriteLine(position.ManhattanDistance);
        }