Untitled
unknown
plain_text
3 years ago
490 B
4
Indexable
# Find the length of the input list
n = len(input_list)
# Find the length of each sublist
m = len(input_list[0])
# Initialize the output list with empty sublists
output_list = [[] for _ in range(n+m-1)]
# Loop through each cell in the input matrix
for i in range(n):
for j in range(m):
# Append the cell to the appropriate diagonal in the output list
output_list[i-j+n-1].append(input_list[i][j])
return output_listEditor is loading...