+ Reply to Thread
Results 1 to 7 of 7

Arrange balls in bins

  1. #1
    Registered User
    Join Date
    12-24-2015
    Location
    India
    MS-Off Ver
    2013
    Posts
    1

    Lightbulb Arrange balls in bins

    Hi,

    I am Aman Ratan, a mechanical engineer and i am currently involved in beam calculation for more than 5 supports.

    Its an uncharted territory so to speak.

    The problem statement is as follows ---



    I want to distribute 'N' number of units (each with value 10) into '4' groups and then obtain the sum of those groups individually in the form of a list (All Possible combinations and not permutations).



    Its easier if i explain it with an example,

    Suppose the number is 1000

    dividing it into 100 parts, we get 100 units each with value 10.

    now lets consider combinations in which these 100 units can be distributed into as 4 sets.

    i.e. 97 - 1 - 1 - 1
    next can be 96 - 2 - 1 - 1
    then 95 - 3 - 1 - 1

    and so on till 1 - 1 - 1 - 97


    The aim is to develop a program that can list all the possible combinations like above (not permutations)

    Sorry for the inability to convey the problem statement properly.

    Any help will be appreciated.

    *Admins, not sure if i have posted the problem in the appropriate thread. If not please make neccessary changes at your discretion.
    Last edited by amanratan; 12-26-2015 at 01:47 PM.

  2. #2
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: A very challenging programming combinatorics problem.

    97 - 1 - 1 - 1
    ...
    and so on till 1 - 1 - 1 - 97
    ...
    (not permutations)
    1-1-1-97 is a permutation of 97-1-1-1 so this routine would return only one of them, not both.

    Perhaps this will do what you want.
    I also think that it might be wise for you (or one of the mods) to remove the email address from your post.
    Note that the shape of ElementsSummingTo(100,4) is 4 rows by 7153 columns.

    Please Login or Register  to view this content.
    Last edited by mikerickson; 12-24-2015 at 07:11 AM.
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. Thank you.

  3. #3
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,929

    Re: A very challenging programming combinatorics problem.

    amanratan welcome to the forum

    Please take a moment to read the forum rules and then amend your thread title to something descriptive of your problem - not what you think the answer might be. (think google search terms?). Once you have done this please send me a PM and I will remove this request. (Also, include a link to your thread - copy from the address bar)

    Many members search our previous posts, and thread titles play a big part of the search. I doubt anybody would do a search based on your title?

    To change a Title on your post, click EDIT POST then Go Advanced and change your title, if 2 days have passed ask a moderator to do it for you.

    (note: this change is not optional )
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  4. #4
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: A very challenging programming combinatorics problem.

    I would understand your problem as, "list the ways in which I can arrange N balls into M distinct bins, with no bins empty", which is =COMBIN(N-1, M-1)

    E.g., for N=100 and M=4, =combin(100-1, 4-1) = 156849:


    Row\Col
    A
    B
    C
    D
    1
    1
    1
    1
    97
    2
    1
    1
    2
    96
    3
    1
    1
    3
    95
    4
    1
    1
    4
    94
    5
    1
    1
    5
    93
    6
    1
    1
    6
    92
    156843
    95
    2
    1
    2
    156844
    95
    2
    2
    1
    156845
    95
    3
    1
    1
    156846
    96
    1
    1
    2
    156847
    96
    1
    2
    1
    156848
    96
    2
    1
    1
    156849
    97
    1
    1
    1


    Ensemble, those are not combinations, permutations, or partitions, just particular arrangments.

    If that's it, I suggest you change your thread title to "Arrange balls in bins"
    Last edited by shg; 12-24-2015 at 01:53 PM.
    Entia non sunt multiplicanda sine necessitate

  5. #5
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Arrange balls in bins

    Row\Col
    B
    C
    D
    E
    F
    2
    Balls
    Bins
    3
    20
    4
    4
    # Arrangements
    5
    969
    6
    7
    Arr #
    Bin 1
    Bin 2
    Bin 3
    Bin 4
    8
    1
    17
    1
    1
    1
    9
    2
    16
    2
    1
    1
    10
    3
    16
    1
    2
    1
    11
    4
    16
    1
    1
    2
    12
    5
    15
    3
    1
    1
    13
    6
    15
    2
    2
    1
    14
    7
    15
    2
    1
    2
    15
    8
    15
    1
    3
    1
    16
    9
    15
    1
    2
    2
    17
    10
    15
    1
    1
    3
    18
    11
    14
    4
    1
    1
    19
    12
    14
    3
    2
    1
    20
    13
    14
    3
    1
    2


    See the workbook at https://app.box.com/s/d6mo50rxjiipx01xj9sv15soh8rna8nd

    The genesis of the formula is this:

    Imagine N balls in a row. You can insert a divider between any two adjacent balls to partition them into bins. To create M bins, you need M-1 dividers, and there are N-1 slots to choose from. So =COMBIN(N-1, M-1) gives the number of arrangements.
    Last edited by shg; 12-26-2015 at 02:38 PM.

  6. #6
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: Arrange balls in bins

    I'm not sure what the repeated injunction "not permuations" means in this context.
    Shg's solution has what some might call permutations, but the so does the OP questions.

  7. #7
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Arrange balls in bins

    I think about permutations as ordered rearrangements of a set (or a subset of a set). I can't see what set this list is the permutations of.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Challenging Problem
    By Raiju02 in forum Excel General
    Replies: 3
    Last Post: 12-19-2011, 10:58 AM
  2. Really challenging problem
    By excelfool1 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-08-2011, 10:23 PM
  3. combinatorics with words
    By jrtaylor in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-12-2011, 05:45 PM
  4. Combinatorics Question
    By wondering2 in forum Excel General
    Replies: 3
    Last Post: 11-15-2010, 02:01 AM
  5. Data filtering problem - challenging!
    By Cumberland in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 05-02-2007, 04:00 AM
  6. Challenging Problem
    By Naji in forum Excel General
    Replies: 1
    Last Post: 01-11-2006, 01:10 PM
  7. Challenging Graph problem!
    By Qwerty in forum Excel Charting & Pivots
    Replies: 2
    Last Post: 12-13-2005, 11:54 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1