[ale] a math/cs question
Greg Freemyer
greg.freemyer at gmail.com
Thu Apr 17 14:37:59 EDT 2008
Jerry,
The number of bags is more important than you are giving it credit for.
If only 5 bags, then 5 factorial is 120, so there are only 120 ways
you can order the bags. With that few, you could just try every
possible ordering of the bags, then simply place them into the buckets
one at a time. If a bag won't fit, move to the next bucket. Then
record the buckets needed for each of the 120 possibilities and pick
the smallest answer.
You should be able to code that up pretty quick and it would not waste
too much cpu time.
OTOH, 20 factorial is 2.4 * 10^18 (if I read
http://en.wikipedia.org/wiki/Factorial correctly).
For that you really do need to have an algorithm that is smarter about
the process of putting bags into buckets.
Greg
2008/4/17 Jerry Yu <jjj863 at gmail.com>:
> Given a varying # of bags, each containing a varying # of golf balls.
> what's the best/practical algorithm to sort these bags to the fewest
> buckets. The buckets can hold varying # of golf balls. assume bags don't
> consume space.
> If the actual # matters, assume 5~20 bags, 10~500 balls per bag, 500~600
> balls per bucket.
>
> I thought some one else on the list asked for similar things for backup
> grouping. couldn't find in my own ALE archive in gmail :(
>
>
> _______________________________________________
> Ale mailing list
> Ale at ale.org
> http://mail.ale.org/mailman/listinfo/ale
>
>
--
Greg Freemyer
Litigation Triage Solutions Specialist
http://www.linkedin.com/in/gregfreemyer
First 99 Days Litigation White Paper -
http://www.norcrossgroup.com/forms/whitepapers/99%20Days%20whitepaper.pdf
The Norcross Group
The Intersection of Evidence & Technology
http://www.norcrossgroup.com
More information about the Ale
mailing list