#Python 2 + NumPy, 122 bytes
Python 2 + NumPy, 122 bytes
I admit it. I worked ahead. Unfortunately, this same method cannot be easily modified to solve the other 2 related challenges...
import numpy def f(m):w=len(m);print sum([list(m[::-1,:].diagonal(i)[::(i+w+1)%2*-2+1])for i in range(-w,w+len(m[0]))],[]) Takes a numpy array as input. Outputs a list.
###Explanation:
Explanation:
def f(m): w=len(m) # the height of the matrix, (at one point I thought it was the width) # get the anti-diagonals of the matrix. Reverse them if odd by mapping odd to -1 d=[list(m[::-1,:].diagonal(i)[::(i+w+1)%2*-2+1])for i in range(-w,w+len(m[0]))] # w+len(m[0]) accounts for the width of the matrix. Works if it's too large. print sum(d,[]) # join the lists A lambda is the same length:
import numpy lambda m:sum([list(m[::-1,:].diagonal(i)[::(i+len(m)+1)%2*-2+1])for i in range(-len(m),len(m)+len(m[0]))],[])