2 ms·
What data structure are you using to represent your matrix? A list of lists? If so, it's not terribly difficult: >>> a = [[1,2,3], [4,5,6], [7,8,9]] >>
by kisielk 14y ago
What data structure are you using to represent your matrix? A list of lists? If so, it's not terribly difficult:
>>> a = [[1,2,3], [4,5,6], [7,8,9]]
>>> b = zip(*map(reversed, reversed(a))
>>> b
[(9, 6, 3), (8, 5, 2), (7, 4, 1)]
>>> reduce(operator.add, b) # could also use a lambda with + instead of operator.add...
(9, 6, 3, 8, 5, 2, 7, 4, 1)