Why isn’t the for loop iterating through 1?

# Why isn't 1 used as x in the first for loop

```
def full_bin(list_in, max):
count = -1
left = list_in
bin_f = []
for x in list_in:
print x
ind_x = list_in.index(x)
stop = 0
for y in list_in[ind_x + 1:]:
print "(%d)" % (y)
if stop == 1:
pass
elif x + y == max:
bin_f.append([])
count += 1
bin_f[count].append(left.pop(left.index(x)))
bin_f[count].append(left.pop(left.index(y)))
stop = 1
return bin_f
print full_bin([3, 2, 1, 5, 4], 5)
```

Its the full bin packing algorithm. Its where you have list of objects of different sizes and you have to fit it into different bins with a max size.

This part of the code is pairing up two numbers in the list that have a total sum equal to the maximum size.

here’s another failed attempt that kind of worked.

The part where it stops working is because some numbers are not iterated through the for loop.

Btw the first function is a different algorithm that does the same thing but does not lead to the best solution. It has to be used for this algorithm to be completed.

**mtf**#11

Can we assume that there are no values in the list greater than max?

If so, then,

```
>>> def full_bin(x, max):
bin_f = []
temp = sorted(x)
while len(temp) > 0:
if temp[0] + temp[-1] == max:
bin_f.append([temp.pop(0), temp.pop(-1)])
elif temp[-1] == max:
bin_f.append([temp.pop(-1)])
return bin_f
>>> n = [3,2,1,5,4]
>>> print (full_bin(n,5))
[[5], [1, 4], [2, 3]]
>>>
```