public void HackerRankSampleBTest() { int[][] m = GetInputMatrixFromFile(_sTestDataRootDir + "sample2_input.txt"); int expectedResult = 5; int result = ConnectedCellsInAGrid.connectedCell(m); Assert.AreEqual(result, expectedResult); }
public void Should_return_the_greates_region_when_asked_for_it() { var grid = new[] { new[] { 1, 1, 0, 0 }, new[] { 0, 1, 1, 0 }, new[] { 0, 0, 1, 0 }, new[] { 1, 0, 0, 0 } }; var sut = new ConnectedCellsInAGrid(grid); var greatesArea = sut.GetGreatesRegion(); Assert.Equal(5, greatesArea); }
public void Rectangle2MultipleRegionsTest() { int[][] m = GetInputMatrixFromFile(_sTestDataRootDir + "rectangle_size2_input.txt"); //ConnectedCellsInAGrid.InitMatrix(m); //ConnectedCellsInAGrid.ColorMatrixRegions(); //ConnectedCellsInAGrid.PrintMatrix(); //int result = ConnectedCellsInAGrid.GetMaxColoredRegionSize(); int result = ConnectedCellsInAGrid.connectedCell(m); int expectedResult = 6; Assert.AreEqual(result, expectedResult); }
public void Circle1Test() { int[][] m = GetInputMatrixFromFile(_sTestDataRootDir + "circle1_input.txt"); //ConnectedCellsInAGrid.InitMatrix(m); //ConnectedCellsInAGrid.ColorMatrixRegions(); //ConnectedCellsInAGrid.PrintMatrix(); //int result = ConnectedCellsInAGrid.GetMaxColoredRegionSize(); int result = ConnectedCellsInAGrid.connectedCell(m); int expectedResult = 10; Assert.AreEqual(result, expectedResult); }
public void MainFlow(string inputString) { var algor = new ConnectedCellsInAGrid(); var input = new StringReader(inputString); int n = Convert.ToInt32(input.ReadLine()); int m = Convert.ToInt32(input.ReadLine()); int[][] matrix = new int[n][]; for (int i = 0; i < n; i++) { matrix[i] = Array.ConvertAll(input.ReadLine().Split(' '), matrixTemp => Convert.ToInt32(matrixTemp)); } int result = algor.connectedCell(matrix); }
public void PrintNeighborPointCoordsTest() { int[][] m = GetInputMatrixFromFile(_sTestDataRootDir + "sample1_input.txt"); ConnectedCellsInAGrid.InitMatrix(m); var refpoint = ConnectedCellsInAGrid.GetPointAt(0, 0); ConnectedCellsInAGrid.PrintNeighborCoords(refpoint); Debug.WriteLine(""); refpoint = ConnectedCellsInAGrid.GetPointAt(0, 2); ConnectedCellsInAGrid.PrintNeighborCoords(refpoint); Debug.WriteLine(""); refpoint = ConnectedCellsInAGrid.GetPointAt(2, 0); ConnectedCellsInAGrid.PrintNeighborCoords(refpoint); Debug.WriteLine(""); refpoint = ConnectedCellsInAGrid.GetPointAt(3, 3); ConnectedCellsInAGrid.PrintNeighborCoords(refpoint); Debug.WriteLine(""); refpoint = ConnectedCellsInAGrid.GetPointAt(2, 3); ConnectedCellsInAGrid.PrintNeighborCoords(refpoint); Debug.WriteLine(""); Assert.IsTrue(true); }