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()); }
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); }