Graphs
Data Structures
Given any matrix, NxN or MxN we should be able to extract the inner matrix.
For example:
MxN [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12]] -> [[6, 7]]
NxN [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16]] -> [[6, 7], [10, 11]]
innerMatrix = array => array
.slice(1, array.length - 1)
.map(row => row.slice(1, array[0].length - 1));
describe("Basic Tests", function(){
it("It should works for basic tests.", function(){
Test.assertEquals(innerMatrix([[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12]]).join('.').toString(),'6,7')
Test.assertEquals(innerMatrix([[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16]]).join('.').toString(),'6,7.10,11')
Test.assertEquals(innerMatrix([[1, 2], [5, 6]]).join('.').toString(),'')
Test.assertEquals(innerMatrix(
[[1, 2, 3, 4, 5],
[6, 7, 8, 9, 10],
[11, 12, 13, 14, 15],
[16, 17, 18, 19, 20],
[21, 22, 23, 24, 25],
[26, 27, 28, 29, 30]]).join('.').toString()
,'7,8,9.12,13,14.17,18,19.22,23,24')
})})