예제 #1
0
        public string SolveFirstTask()
        {
            var robot    = new Robot();
            var computer = new OpCodeComputer.OpCodeComputer(null, robot);

            computer.ProcessInstructions(_program);

            Map = robot.GetMap();
            var intersections = GetIntersections(Map).ToList();

            ToConsoleDrawer.DrawFromDictionary(Map, ' ');

            return(intersections.Select(coor => coor.X * coor.Y).Sum().ToString());
        }
예제 #2
0
파일: Droid.cs 프로젝트: okubicek/Exercises
        public long GetNext()
        {
            var nextDirection = GetNextDirection();

            if (nextDirection == Direction.NotSpecified)
            {
                if (_backTrace.TryPop(out var dir))
                {
                    nextDirection = dir;
                    _backtracing  = true;
                }
                else
                {
                    ToConsoleDrawer.DrawFromDictionary(_map, ' ');
                    throw new Exception("Whole Map has been scanned");
                }
            }

            _lastDirectionCommand = nextDirection;
            return((long)nextDirection);
        }