How to make weighted queue in Python? -
i have list of dictionaries in python , variable specifying total amount of items split between first list items.
lista= [ {'name': 'one', 'priority': 3 }, {'name': 'two', 'priority': 6 }, {'name': 'three', 'priority': 1 } ] items_to_split= 20 i'm trying find way how assign appropriate amount of items items_to_split items lista based on priority.count of items in first list might various. higher item priority more items 20 should get. in example i'm looking result this: (example case ideal because there no remain after division)
one: 6 two: 12 three: 2
or
one 1 one 1 one 1 2 two 2 two 2 two 2 two 2 two 2 two 3 three
calculated weight per 1 priority point - 20/(3+6+1) = 2, , multiplying priority of item number.
there way how smarted in python using queues or other method ? thank you
Comments
Post a Comment