Ejemplo n.º 1
0
        private void RandomTest(Random rand, Action <int[], int[]> assert)
        {
            int[,] map = GetRandomMap(rand);

            int[] weight = GetRandomWeight(rand, map.GetLength(0));

            int[] expected = new PowerSet().Solve(map, weight);

            DebugDump(map, weight, expected);

            SolverNonFancy target = new SolverNonFancy();
            var            actual = target.SolveNonFancy(map, weight);

            Debug.WriteLineIf(actual.Length < expected.Length, "Diff = " + (expected.Length - actual.Length).ToString());
            assert(expected, actual);
        }
Ejemplo n.º 2
0
        public void SolveTest_5X3Case()
        {
            int[,] map =
            {
                { 1, 1, 0, 1, 1 },
                { 0, 1, 1, 1, 0 },
                { 0, 1, 1, 0, 0 },
            };

            int[] weight =
            {
                3,
                2,
                1
            };

            int[] expected    = { 0, 2, 3, 4 };
            int[] powerSolver = new PowerSet().Solve(map, weight);

            SolverNonFancy target = new SolverNonFancy();
            var            actual = target.SolveNonFancy(map, weight);

            CollectionAssert.AreEqual(expected, actual);
        }