A
Alexander Schmolck
Quite a few algortihms prominently feature choosing/removing a single random
element from a set at a time. On first sight I can't think of anything better
to achieve this with `sets.Set` than something along the lines of:
for dummy, randomElement in zip(range(randrange(len(s)+1)), s): pass
# possibly followed by
s.remove(randomElement)
Is there a better way? If not, how about something like Set.randompop()?
'as
element from a set at a time. On first sight I can't think of anything better
to achieve this with `sets.Set` than something along the lines of:
for dummy, randomElement in zip(range(randrange(len(s)+1)), s): pass
# possibly followed by
s.remove(randomElement)
Is there a better way? If not, how about something like Set.randompop()?
'as