Data distribution by frequency
Greg Fortune
gfortune_ewu at ispchannel.com
Sat Oct 7 19:45:58 EDT 2000
I have several objects that I need to arrange in a list based on their
respective frequency. I'm basically trying to set up an intelligent user
modifiable timing loop.
Obj1
Frequency: 2
Obj2
Frequency:2
should yeild
[Obj1, Obj2, Obj1, Obj2]
Something a little nastier like
Obj1
Frequency: 3
Obj2
Frequency: 2
Obj3
Frequency: 1
Obj4
Frequency: 2
Should yield
[Obj1, Obj2, Obj4, Obj1, Obj3, Obj2, Obj1, Obj4]
or something very similar.
The only idea I have on the matter is take the most frequently occuring
object and distribute it through the list at the appropriate intervals (i.e.
total_size/obj1_freq). Then, create a temp list of the available elements
and do the same thing with the next most frequently occuring object and the
new list.
Sound good? Or is there an easier/cleaner way to accomplish the same thing?
Anyone know of any resources I can look at for information? Implementation
language doesn't really matter either.
Greg Fortune
Eastern Washington University Student
Why is it, that coding C++ just isn't quite as cool now as it was before I
learned Python? ;o) - Me
More information about the Python-list
mailing list