Balls in boxes algorithm
February 9, 2007 1:35 PM
Subscribe
Is there a standard ball picking algorithm? I have 10 balls that I want put in four boxes (A-D). Every box can hold zero to all balls.
So one possible combination is:
box A: 0,1,3
box B: 5
box C: 2,4,6,7,8,9
box D: -
I want to generate all possible combinations. I realise that this makes 4^10, which is over 1 million possibilities so efficiency is important.
I expected that this would be a common homework problem for computer scientists and I assumed there would be a sort-of standard way to do this (like "quicksort" is a standard way to sort). I don't think I know the terms to search for though, because I cannot find anything.
Any help with this specific problem would be appreciated (pseudo code is fine). If there is a language that is exceptionally suited for this kind of task, I would be interested in that as well. If there are useful websites about this problem, that would be great as well.
posted by davar to science & nature (10 comments total)
3 users marked this as a favorite
AAAAAAAAAA
AAAAAAAAAB
etc.
posted by chairface at 1:44 PM on February 9, 2007