def scan_diag(direction): if direction == 'right': start = 0 stop = len(grid) increment = 1 else: start = len(grid) stop = 0 increment = -1 for x in range(start, stop, increment): diag = [] x_cord = x y_cord = 0 for _ in xrange(len(grid)): if x_cord >= len(grid) or y_cord >= len(grid): break elif x_cord < 0 or y_cord < 0: break else: diag.append(grid[y_cord][x_cord]) x_cord += increment y_cord += 1 adjacent_items.extend(find_consecutive_chunks(diag, n))
def scan_vertical(): for x in xrange(0, len(grid[0])): column = [] for y in xrange(len(grid)): column.append(grid[y][x]) adjacent_items.extend(find_consecutive_chunks(column, n))
def scan_horizontal(): for row in grid: adjacent_items.extend(find_consecutive_chunks(row, n))