Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Uncategorized category for Transposed Matrix by Mahoter
def checkio(data):
a = 0
res = []
while a < len(data):
temp = list(data[a])
if a == 0:
for num in temp:
res += [[num]]
else:
b = 0
for num in temp:
c = []
row = list(res[b])
for digit in row:
c += [digit]
c += [num]
res[b] = c
b += 1
a+=1
#replace this for solution
return res
#These "asserts" using only for self-checking and not necessary for auto-testing
if __name__ == '__main__':
assert isinstance(checkio([[0]]).pop(), list) is True, "Match types"
assert checkio([[1, 2, 3],
[4, 5, 6],
[7, 8, 9]]) == [[1, 4, 7],
[2, 5, 8],
[3, 6, 9]], "Square matrix"
assert checkio([[1, 4, 3],
[8, 2, 6],
[7, 8, 3],
[4, 9, 6],
[7, 8, 1]]) == [[1, 8, 7, 4, 7],
[4, 2, 8, 9, 8],
[3, 6, 3, 6, 1]], "Rectangle matrix"
Jan. 17, 2016