public static void Main()
        {
            map = Labirynth.CreateLabirynth();
            var queue = new Queue <Point>();

            queue.Enqueue(new Point {
                X = 0, Y = 0
            });
            while (queue.Count != 0)
            {
                var point = queue.Dequeue();
                if (!CanMove(point.X, point.Y))
                {
                    continue;
                }
                map[point.X, point.Y] = Space.Visited;
                Visualize();
                queue.Enqueue(new Point {
                    X = point.X - 1, Y = point.Y
                });
                queue.Enqueue(new Point {
                    X = point.X + 1, Y = point.Y
                });
                queue.Enqueue(new Point {
                    X = point.X, Y = point.Y - 1
                });
                queue.Enqueue(new Point {
                    X = point.X, Y = point.Y + 1
                });
            }
        }
Пример #2
0
        public static void MainX()
        {
            var l     = Labirynth.CreateLabirynth();
            var str   = "([{()[][]{}}])";
            var stack = new Stack <char>();
            var dict  = new Dictionary <char, char>
            {
                { '}', '{' },
                { ')', '(' },
                { ']', '[' }
            };

            foreach (var e in str)
            {
                if (dict.Values.Contains(e))
                {
                    stack.Push(e);
                }
                else if (dict.Keys.Contains(e))
                {
                    if (dict[e] != stack.Pop())
                    {
                        throw new Exception("");
                    }
                }
            }
        }