private static void ValidDirectory()
        {
            Console.Write("> Your current directory is ");
            Console.ForegroundColor = ConsoleColor.Green;
            Console.Write("valid ");
            Console.ResetColor();
            Console.WriteLine("for generating code.");

            if (!ValidPaths.ContainsKey(Program.CurrentDirectory))
            {
                ValidPaths.Add(Program.CurrentDirectory, true);
            }
        }
        public static void NotValidDirectory()
        {
            Console.Write("> Your current directory is ");
            Console.ForegroundColor = ConsoleColor.Red;
            Console.Write("not valid ");
            Console.ResetColor();
            Console.WriteLine("for generating code.");

            if (!ValidPaths.ContainsKey(Program.CurrentDirectory))
            {
                ValidPaths.Add(Program.CurrentDirectory, false);
            }

            Program.EmptyLine();
        }
Ejemplo n.º 3
0
        private void FindValidPaths(int i, int j, IList <int> currentPath)
        {
            currentPath.Add(_data[i][j]);

            // if bottom is reached, add currentPath to ValidPaths
            if (currentPath.Count == _data.Length)
            {
                ValidPaths.Add(currentPath);
            }

            // save currentPath length in order to know how many items to copy to possible alternative path
            var currentPathLength    = currentPath.Count;
            var needsAlternativePath = false;

            var nextValidItemsQueue = GetNextValidItems(i, j);

            while (nextValidItemsQueue.TryDequeue(out (int i, int j)item))
            {
                FindValidPaths(item.i, item.j, needsAlternativePath ? currentPath.Take(currentPathLength).ToList() : currentPath);
                needsAlternativePath = true;
            }
        }