I have a really simple algorithm that's meant to sort some 48 numbers into buckets with specific ranges. For example, if my ranges are [0, 16), [16, 32), [32, 48)
I would have 3 buckets with 16 integers each.
ds = range(0, 48)
bounds = [[0, 16], [16, 32], [32, 48]]
acd = [[]] * len(bounds)
for d in ds:
for i in range(0, len(bounds)):
if bounds[i][0] <= d < bounds[i][1]:
print("Adding %s to %s" % (d, i))
acd[i] += [d]
The print statement works as expected, for example it will print "Adding 47 to 2"
However, the array acd
which is supposed to contain the buckets, has all 48 elements in all 3 buckets. I'm kind of lost as to why this could be happening since it's such a simple algorithm.