bin packing algorithm python

Solutions on MaxInterview for bin packing algorithm python by the best coders in the world

showing results for - "bin packing algorithm python"
Maissane
15 Jan 2018
1>>> import binpacking
2>>>
3>>> b = { 'a': 10, 'b': 10, 'c':11, 'd':1, 'e': 2,'f':7 }
4>>> bins = binpacking.to_constant_bin_number(b,4) # 4 being the number of bins
5>>> print("===== dict\n",b,"\n",bins)
6===== dict
7 {'a': 10, 'b': 10, 'c': 11, 'd': 1, 'e': 2, 'f': 7}
8 [{'c': 11}, {'b': 10}, {'a': 10}, {'f': 7, 'e': 2, 'd': 1}]
9>>>
10>>> b = list(b.values())
11>>> bins = binpacking.to_constant_volume(b,11) # 11 being the bin volume
12>>> print("===== list\n",b,"\n",bins)
13===== list
14 [10, 10, 11, 1, 2, 7]
15 [[11], [10], [10], [7, 2, 1]]
16