Message358400
For the record, this is an easy application of itertools.combinations:
>>> def segment(s, m):
... for c in itertools.combinations(range(1, len(s)), m-1):
... yield tuple(s[i:j] for i, j in zip((0,)+c, c+(len(s),)))
...
>>> list(segment("12345", m=3))
[('1', '2', '345'), ('1', '23', '45'), ('1', '234', '5'), ('12', '3', '45'), ('12', '34', '5'), ('123', '4', '5')] |
|
Date |
User |
Action |
Args |
2019-12-14 18:22:37 | mark.dickinson | set | recipients:
+ mark.dickinson, SilentGhost, lovi |
2019-12-14 18:22:37 | mark.dickinson | set | messageid: <1576347757.27.0.580402265329.issue39045@roundup.psfhosted.org> |
2019-12-14 18:22:37 | mark.dickinson | link | issue39045 messages |
2019-12-14 18:22:37 | mark.dickinson | create | |
|