GO : Partitioning any matrix

 // You can edit this code!

// Click here and start typing.

package main


import "fmt"


func main() {

a := [][]float64{{1, 3, 5, -6}, {5, 2, 9, -4}, {10, 5, 6.2, 1}, {0.005, 2, 6.8, -4}}

fmt.Println(a)

fmt.Println(partMat(a, 2, 3, 1, 4))

}

func partMat(a [][]float64, rowStart int, rowEnd int, colStart int, colEnd int) [][]float64 {

c := [][]float64{}


for i := rowStart - 1; i <= rowEnd-1; i++ {

k := []float64{}

for j := colStart - 1; j <= colEnd-1; j++ {

k = append(k, a[i][j])

}

c = append(c, k)

}

return c

}