Created
November 24, 2015 06:06
-
-
Save shuson/c0a2f1598662b7e8b1ac to your computer and use it in GitHub Desktop.
Matrix Transpose From list
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
given list[1,2,3,4,5,6,7,8,9,10], and delimter as 5, | |
output is as [1,6,2,7,3,8,4,9,5,10] | |
""" | |
def matricTranspos(ls, delimter): | |
length = len(ls) | |
parts = length/delimter | |
matrics = [ls[i*delimter:(i+1)*delimter] for i in range(parts)] | |
transposed = [[row[i] for row in matrics] for i in range(delimter)] | |
return reduce(lambda c, x: c + x, transposed, []) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment