I’m trying to combine a matrice into a single list. I’ve tried to wrap my head around tree traversals / 0(n*expression) stuff that i keep finding via search. I really don’t think this problem is as hard as i’m making it out to be!?
# example of what output should be
# ('147','258','369')
m = [1,2,3]
n = [4,5,6]
o = [7,8,9]
def myFun(*args):
return [zip(args[x][i]) for x in args for i in args[x]]
print(myFun(m,n,o))
For future reference, would using a map be a smarter approach for handling matrices in this manor? I’ve read that maps can apply a function to every element, as such i was skeptical about using such a method and getting additional output (e.g. [(‘471′,’582′,’693’, and so on)]
What this comes down to is transposing the matrix. This can be done with
Once we have this, we can join each row to form a new integer, and place these values in a new list: