예제 #1
0
        public void Mazing7x7()
        {
            int[][] mazing =
            {
                new int[] { 1, 1, 1, 1, 1, 1, 1 },
                new int[] { 1, 0, 1, 1, 1, 1, 1 },
                new int[] { 1, 1, 0, 1, 1, 1, 1 },
                new int[] { 1, 1, 1, 0, 1, 1, 1 },
                new int[] { 1, 1, 1, 0, 1, 1, 1 },
                new int[] { 1, 1, 1, 1, 0, 0, 1 },
                new int[] { 1, 1, 1, 1, 1, 1, 0 }
            };

            var ExpectedPath = new List <string>()
            {
                "(1,1)",
                "(2,2)",
                "(3,3)",
                "(4,3)",
                "(5,4)",
                "(5,5)",
                "(6,6)",
            };

            var     solution = new MazingProblem();
            MyStack path     = solution.FindPath(mazing, 7, 7);

            Assert.AreEqual(ForamtPath(ExpectedPath), solution.FormatPath(path));
        }
예제 #2
0
        public void FormatPathTest()
        {
            var ExpectedPath = new List <string>()
            {
                "(1,1)",
                "(2,2)"
            };
            var solution = new MazingProblem();

            MyStack path = new MyStack(ExpectedPath.Count);

            path.Push("(1,1)");
            path.Push("(2,2)");

            Assert.AreEqual(ForamtPath(ExpectedPath), solution.FormatPath(path));
        }
예제 #3
0
        public void Mazing11x11()
        {
            int[][] mazing =
            {
                new int[] { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 },
                new int[] { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 },
                new int[] { 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1 },
                new int[] { 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1 },
                new int[] { 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1 },
                new int[] { 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1 },
                new int[] { 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1 },
                new int[] { 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1 },
                new int[] { 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1 },
                new int[] { 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1 },
                new int[] { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0 }
            };

            var ExpectedPath = new List <string>()
            {
                "(1,1)",
                "(1,2)",
                "(1,3)",
                "(1,4)",
                "(1,5)",
                "(1,6)",
                "(1,7)",
                "(1,8)",
                "(1,9)",
                "(2,9)",
                "(3,8)",
                "(3,7)",
                "(3,6)",
                "(3,5)",
                "(3,4)",
                "(3,3)",
                "(3,2)",
                "(4,1)",
                "(5,2)",
                "(5,3)",
                "(5,4)",
                "(5,5)",
                "(5,6)",
                "(5,7)",
                "(5,8)",
                "(5,9)",
                "(6,9)",
                "(7,8)",
                "(7,7)",
                "(7,6)",
                "(7,5)",
                "(7,4)",
                "(7,3)",
                "(7,2)",
                "(8,1)",
                "(9,2)",
                "(9,3)",
                "(9,4)",
                "(9,5)",
                "(9,6)",
                "(9,7)",
                "(9,8)",
                "(9,9)",
                "(10,10)"
            };

            var     solution = new MazingProblem();
            MyStack path     = solution.FindPath(mazing, 11, 11);

            Assert.AreEqual(ForamtPath(ExpectedPath), solution.FormatPath(path));
        }