diff --git a/go/matrix/matrix.go b/go/matrix/matrix.go new file mode 100644 index 0000000..c2bbfcf --- /dev/null +++ b/go/matrix/matrix.go @@ -0,0 +1,34 @@ +package matrix + +import "strings" + +type Matrix struct { + vals [][]int +} + +func New(in string) (*Matrix, error) { + ret := Matrix{} + rows := strings.Split(in, "\n") + return &ret, nil +} + +func (m *Matrix) Rows() [][]int { + return m.vals +} + +func (m *Matrix) Cols() [][]int { + ret := [][]int{} + if len(m.vals) > 0 { + // for i := 0; i < len(m.vals[0]); i++ { + // } + } + return ret +} + +func (m *Matrix) Set(r, c int, val int) bool { + if len(m.vals) < r || len(m.vals[r]) < c { + return false + } + m.vals[r][c] = val + return true +}