Exemple #1
0
        public void Should_return_count_of_one_for_adjacent_ints_When_all_values_are_same()
        {
            var gridWindow = new GridAdjacentIntegerWindow(new int[][]
            {
                new int[] { 1, 1, 1 },
                new int[] { 1, 1, 1 },
                new int[] { 1, 1, 1 },
            }, 0, 0, 3);

            var expectedCount = 1;

            distinctAdjacentGridVisitor.VisitGridWindow(gridWindow);

            Assert.AreEqual(expectedCount, distinctAdjacentGridVisitor.GetDistinctCount());
        }
        /// <summary>
        /// Calculates the number of distinct three adjacent numbers
        /// </summary>
        /// <param name="searchGrid">search grid data</param>
        /// <returns>distinct number of three adjacent numbers</returns>
        public int DistinctThreeAdjacentNumbers(int[][] searchGrid)
        {
            ArgumentCheck.IsNull(searchGrid, nameof(searchGrid));

            var distinct3AdjacentGridVisitor = new Distinct3AdjacentGridVisitor();
            var grid = new Grid(searchGrid, 3);

            grid.Apply(distinct3AdjacentGridVisitor);

            return(distinct3AdjacentGridVisitor.GetDistinctCount());
        }