Files
python/exercises/matrix/example.py
Marc Chan 57a700e508 matrix: re-implement to conform with canonical data (#1297)
* matrix: Rewrite tests to match canonical v1.0.0

* matrix: add necessary methods to stub file

* matrix: fix example to pass tests v1.0.0
2018-02-16 14:03:08 -06:00

12 lines
333 B
Python

class Matrix(object):
def __init__(self, s):
self.rows = [[int(n) for n in row.split()]
for row in s.split('\n')]
self.columns = [list(tup) for tup in zip(*self.rows)]
def row(self, index):
return self.rows[index]
def column(self, index):
return self.columns[index]