numpy attempt solution in 3rd party category for Zigzag Array by HeNeArKr
# Just playing with numpy. I feel like there is a more efficient way to do this,
# but have not been able to find it yet.
from typing import List
import numpy as np
def create_zigzag(rows: int, cols: int, start: int = 1) -> List[List[int]]:
""" Return list of lists of ints, starting with start, increasing by one,
with odd-numbered rows increasing from right to left.
if rows == 0:
filter_e = np.array([[i % 2 == 0] for i in range(rows)])
filter_o = np.invert(filter_e)
result_e = np.arange(start, start+rows*cols).reshape(rows, cols)
return (result_e * filter_e + np.fliplr(result_e) * filter_o).tolist()
Oct. 15, 2018