Add python/matrix
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
class Matrix:
|
||||
def __init__(self, matrix_string):
|
||||
self.matrix = []
|
||||
for line in matrix_string.strip().split('\n'):
|
||||
row = []
|
||||
for v in line.split(" "): row.append(int(v))
|
||||
self.matrix.append(row)
|
||||
|
||||
def row(self, index):
|
||||
return self.matrix[index-1]
|
||||
|
||||
def column(self, index):
|
||||
column = []
|
||||
for row in self.matrix: column.append(row[index-1])
|
||||
|
||||
return column
|
||||
Reference in New Issue
Block a user