What does optimal balance mean? In your example case, if you have 10 apples,
put 2 in basket1, 4 in basket2, 4 in basket3 and basket4 gets nothing. If you have to make sure that, each basket gets at least one apple, then start distributing apples one by one to each basket until it reaches its max capacity. But approach may differ upon the definition of optimality. On Wed, Sep 9, 2009 at 11:54 AM, Sandeep .A.S. <reachtosand...@gmail.com>wrote: > > Hi, > > Please let me know is there any standard algorithm to solve the below > mentioned problem. > > Problem statement: > > I am having 10 apples and 4 basket each basket capacity is as mentioned > below: > > Basket1 : capacity can hold maximum of 2 apples > Basket2 : capacity can hold maximum of 4 apples > Basket3 : capacity can hold maximum of 6 apples > Basket4 : capacity can hold maximum of 8 apples > > I want to distribute the apples based on percentage contribution of > each basket to total number of apples can accommodate by all the > basket > > For the above example the 10 apples can be distributed as follows: > > 1 apple for basket1 (10% => (<basket1 capacity>/< total of all basket > capacity>) *100 => (2/20) *100) > 2 apple for basket1(20% =>(<basket2 capacity>/< total of all basket > capacity>) *100 => (4/20) *100) > 3 apples for basket 3(30% => (<basket3 capacity>/< total of all basket > capacity>) *100 => (6/20) *100) > 4 apples for basket 4(40% => (<basket4 capacity>/< total of all basket > capacity>) *100 => (8/20) *100) > > In the above example what if I have 13 apples? What is the best > approach to solution which is near to optimal balance? > > I request you to provide the idea to resolve this problem. > > Thanks & Regards, > Sandeep > > > > -- <<Bharath>> --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegroups.com To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/algogeeks -~----------~----~----~----~------~----~------~--~---