The classmethod Segment._split_cells uses a heuristic to start the search for the cut point that is too eager.
Because the algorithm implemented doesn't backtrack, one can construct example strings for which the cuts have the wrong sizes.
The two examples below show instances of the wrong result being computed.
s = Segment("🦊🦊🦊\n\n\n\n\n\n")
print(Segment._split_cells(s, 3)) # (Segment('🦊🦊🦊\n '), Segment(' \n\n\n\n'))
s = Segment("🦊🦊🦊abcdef")
print(Segment._split_cells(s, 3)) # (Segment('🦊🦊 '), Segment(' abcdef'))
The classmethod
Segment._split_cellsuses a heuristic to start the search for the cut point that is too eager.Because the algorithm implemented doesn't backtrack, one can construct example strings for which the cuts have the wrong sizes.
The two examples below show instances of the wrong result being computed.