Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
[Nested Comprehensions] [Pythonic] solution in Clear category for Zigzag Array by sanddro
def create_zigzag(rows: int, columns: int, start: int = 1) -> list[list[int]]:
return [
[
y
for y in (
range(
columns * row + columns + start - 1, columns * row + start - 1, -1
)
if row % 2
else range(columns * row + start, columns * row + columns + start, 1)
)
]
for row in range(rows)
]
Jan. 19, 2025
Comments: