Esempio n. 1
0
        public void Test_4_VeryHard()
        {
            int index = 1;

            int[]   clues1    = { 0, 0, 0, 5, 0, 0, 3, 0, 6, 3, 4, 0, 0, 0, 3, 0, 0, 0, 2, 4, 0, 2, 6, 2, 2, 2, 0, 0 };
            int[][] expected1 =
            {
                new[] { 3, 5, 6, 1, 7, 2, 4 },
                new[] { 7, 6, 5, 2, 4, 3, 1 },
                new[] { 2, 7, 1, 3, 6, 4, 5 },
                new[] { 4, 3, 7, 6, 1, 5, 2 },
                new[] { 6, 4, 2, 5, 3, 1, 7 },
                new[] { 1, 2, 3, 4, 5, 7, 6 },
                new[] { 5, 1, 4, 7, 2, 6, 3 }
            };
            Stack <int> orderedClues = new Stack <int>(Enumerable.Range(0, 4 * Skyscrapers.Size)
                                                       .Select(clueIndex => new Tuple <int, int[]>(clueIndex, SkyscrapersTests4by4.GetLaneIndices2(clueIndex))).OrderBy(t => t.Item2[0])
                                                       .ThenBy(t => t.Item2[1]).Select(t => clues1[t.Item1]).Reverse());

            Skyscrapers.Expected = expected1;
            var actual = Skyscrapers.SolvePuzzle(clues1);

            CollectionAssert.AreEqual(expected1, actual,
                                      SkyscrapersTests4by4.ErrorMessage(expected1, actual, orderedClues));
        }
Esempio n. 2
0
        public void Test_2_VeryHard()
        {
            int index = 1;

            int[]       clues1       = clues[index];
            int[][]     expected1    = expected[index];
            Stack <int> orderedClues = new Stack <int>(Enumerable.Range(0, 4 * Skyscrapers.Size)
                                                       .Select(clueIndex => new Tuple <int, int[]>(clueIndex, SkyscrapersTests4by4.GetLaneIndices2(clueIndex))).OrderBy(t => t.Item2[0])
                                                       .ThenBy(t => t.Item2[1]).Select(t => clues1[t.Item1]).Reverse());

            var actual = Skyscrapers.SolvePuzzle(clues1);

            CollectionAssert.AreEqual(expected1, actual,
                                      SkyscrapersTests4by4.ErrorMessage(expected1, actual, orderedClues));
        }
Esempio n. 3
0
        public void SolvePuzzle4()
        {
            var clues = new[] { 4, 4, 0, 3, 0, 0, 0, 0, 0, 2, 2, 0, 0, 0, 0, 6, 3, 0, 0, 4, 0, 0, 0, 0 };

            var expected = new[] {
                new [] { 3, 1, 6, 2, 4, 5 },
                new [] { 4, 2, 5, 3, 1, 6 },
                new [] { 2, 5, 4, 6, 3, 1 },
                new [] { 5, 6, 3, 1, 2, 4 },
                new [] { 1, 4, 2, 5, 6, 3 },
                new [] { 6, 3, 1, 4, 5, 2 }
            };

            Stack <int> orderedClues = new Stack <int>(Enumerable.Range(0, 4 * Skyscrapers.Size)
                                                       .Select(clueIndex => new Tuple <int, int[]>(clueIndex, SkyscrapersTests4by4.GetLaneIndices2(clueIndex))).OrderBy(t => t.Item2[0])
                                                       .ThenBy(t => t.Item2[1]).Select(t => clues[t.Item1]).Reverse());

            var actual = Skyscrapers.SolvePuzzle(clues);

            CollectionAssert.AreEqual(expected, actual,
                                      SkyscrapersTests4by4.ErrorMessage(expected, actual, orderedClues));
        }