human
Bin Packing Problem ( Minimize number of used Bins ) | Returns number of bins required using first fit online algorithm.
Initialize result ( Count of bins ).
Create an array to store remaining space in bins there can be at most n bins.
Place items one by one.
Find the first bin that can accommodate weight [ i ].
If no bin could accommodate weight [ i ].
Driver program"
Solution in Python:
assistant
#Here is code to bin Packing Problem ( Minimize number of used Bins ) and the other steps required.
 def firstFit ( weight , n , c ) :
	res = 0
	bin_rem = [ 0 ] * n
	for i in range ( n ) :
		j = 0
		while ( j < res ) :
			if ( bin_rem [ j ] >= weight [ i ] ) :
				bin_rem [ j ] = bin_rem [ j ] - weight [ i ]
				break
			j += 1
		if ( j == res ) :
			bin_rem [ res ] = c - weight [ i ]
			res = res + 1
	return res
weight = [ 2 , 5 , 4 , 7 , 1 , 3 , 8 ]
c = 10
n = len ( weight )
print ( " Number ▁ of ▁ bins ▁ required ▁ in ▁ First ▁ Fit ▁ : ▁ " , firstFit ( weight , n , c ) )