def algorithm(picture, args): """ Keep placing the biggest square possible. When only squares of size 1 are possible, fill with lines. """ painter = Painter(picture.empty_copy()) square = Square(-1, -1, 100000) while True: square = get_largest_unpainted_square(picture, painter, square.size) if not square: break painter.paint_square(square.row, square.column, square.size) for row, column in painter.picture.positions_to_paint(picture): if painter.picture[row][column]: continue length = 0 for i in range(row + 1, picture.shape[0]): if picture[i][column]: length += 1 else: break painter.paint_line(row, column, row + length, column) return painter
def algorithm(picture, args): """ Try to use vertical lines for each cell """ painter = Painter(picture.empty_copy()) for row, column in painter.picture.positions_to_paint(picture): if painter.picture[row][column]: continue length = 0 for i in range(row + 1, picture.shape[0]): if picture[i][column]: length += 1 else: break painter.paint_line(row, column, row + length, column) return painter