I have little problem here. As I am not good in math I can't figure this out tho.
I need to create function that takes n as a parameter which is matrix size and creates matrix of this type
[[1, -8, 9, -16]
[2, -7, 10, -15]
[3, -6, 11, -14]
[4, -5, 12, -13]]
All I achieved was this
def arrange_matrix2(n):
matrix = []
row = []
num = 1
for i in range(n):
for j in range(n):
row.append(num)
num += 1
matrix.append(row)
row = []
final_matrix = map(list, zip(*matrix))
print(*final_matrix)
It creates matrix that looks like this
[1, 4, 7]
[2, 5, 8]
[3, 6, 9]
Also. Is there a way to create matrix that is arranged by column without using zip() function?
Thank you for your time.