Exemplo n.º 1
0
        private static long Input()
        {
            var attempt = Attempts.Pop().Where(dir => !Visited.Contains(Compass.PositionAfterMovement(droidPosition, dir))).ToList();

            if (attempt.Count == 0)
            {
                Backtracking = true;
                Attempt      = Compass.Opposite(EnteredFrom[droidPosition]);
            }
            else
            {
                Backtracking = false;
                Attempt      = attempt[0];
                attempt.RemoveAt(0);
                Attempts.Push(attempt);
            }
            var backTrackingString = Backtracking ? " (BACKTRACKING)" : "";

            Day15Debug.Write($"({droidPosition.x}),{droidPosition.y}) - {Compass.Name(Attempt)}{backTrackingString} : ");
            return(Compass.ToLong(Attempt));
        }