Function
zigzag_path_lr
(N, start_row=0, start_col=0, dir_row=1, dir_col=1)
Source from the content-addressed store, hash-verified
| 143 | |
| 144 | def zigzag_path(N): |
| 145 | def zigzag_path_lr(N, start_row=0, start_col=0, dir_row=1, dir_col=1): |
| 146 | path = [] |
| 147 | for i in range(N): |
| 148 | for j in range(N): |
| 149 | # If the row number is even, move right; otherwise, move left |
| 150 | col = j if i % 2 == 0 else N - 1 - j |
| 151 | path.append((start_row + dir_row * i) * N + start_col + dir_col * col) |
| 152 | return path |
| 153 | |
| 154 | def zigzag_path_tb(N, start_row=0, start_col=0, dir_row=1, dir_col=1): |
| 155 | path = [] |
Tested by
no test coverage detected