17 lines
443 B
Python
17 lines
443 B
Python
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
|