+ Reply to Thread
Results 1 to 2 of 2

How to calculate all possibilities

  1. #1
    Registered User
    Join Date
    11-03-2010
    Location
    Stockholm, Sweden
    MS-Off Ver
    Excel 2007
    Posts
    14

    How to calculate all possibilities

    Hi,

    I have a problem I'm trying to solve. The real problem is a bit hard to describe but one way is to compare it to stones that are to be placed in bags (Bag 1, Bag 2, Bag 3). Lets say I have three stones, then all the ways I can spread them out in the three bags are as follows:

    Bag 1 Bag 2 Bag 3
    3 0 0
    0 3 0
    0 0 3
    2 1 0
    2 0 1
    1 2 0
    0 2 1
    1 0 2
    0 1 2
    1 1 1


    And this is pretty quick to do manually. But if I have 8 stones and 4 bags (or even more stones or more bags). Then this exercise is a bit more time consuming.

    Is there a way to use Excel 2013 to calculate and show all the different way to divided the stones?

    Thanks in advance
    Vic

  2. #2
    Forum Expert
    Join Date
    06-26-2010
    Location
    Austin, TX
    MS-Off Ver
    Excel 2010
    Posts
    1,673

    Re: How to calculate all possibilities

    This is combinatorics. I think I understand your question.

    Think of it this way. You have an array and each element can either contain a stone or a divider to the next bag. That would require (stones+bags-1) elements to handle all possibilities. That is, you can split the stones up into the number of bags by using (bags-1) dividers. So, how many ways are there to place the (bags-1) dividers within that array of size (stones+bags-1)? =COMBIN((stones+bags-1),(bags-1))

    Per your example above, but re-written with
    o=stone
    l=divider

    oooll
    loool
    llooo
    oolol
    oollo
    olool
    loolo
    olloo
    loloo
    ololo

    For 3 bags and 3 stones: COMBIN(5,2) = 10. For 4 bags and 8 stones, COMBIN(11,3)=165.

    As for showing them, that would require some VBA. You should post in that group. I'd probably use my example as a basis for an algorithm.
    Last edited by Pauleyb; 05-19-2015 at 05:08 PM.
    Pauley
    --------
    If I helped with your issue, I'd appreciate a rep bump (hit the '*' icon to the bottom left of this post).

+ 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. IF and AND Function with 3 possibilities
    By Angelicvamp in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 10-28-2014, 01:51 AM
  2. Vlookup & Sum if possibilities
    By dcad81 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 06-26-2013, 06:00 PM
  3. Hyperlink possibilities
    By Vinodsralian in forum Excel General
    Replies: 0
    Last Post: 07-12-2010, 07:08 AM
  4. Excel/VBA possibilities
    By The Alltime Best in forum Excel General
    Replies: 2
    Last Post: 04-30-2006, 04:25 PM
  5. Excel/VBA possibilities
    By The Alltime Best in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-30-2006, 04:25 PM

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