Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Determining Combinations with Restraints

  1. Jul 16, 2012 #1
    I'm loosely familiar with the formulas for combinations and permutations. However, I don't know how to use the formula with restraints.

    Here is the specific issue I am having:

    Number of Objects: 16
    Number of States: 2
    Number of Black Objects 8
    Number of White Objects: 8

    How many unique permutations color permutations are possible?​


    I know that for the first and last 8 both have 2^8 permutations, so there is a minimum of 512 permutations.
     
  2. jcsd
  3. Jul 16, 2012 #2
    I'm sorry, I don't understand the question.
     
  4. Jul 16, 2012 #3

    chiro

    User Avatar
    Science Advisor

    Hey Altermeris and welcome to the forums.

    Your question is unclear but one recommendation to make it clearer is to write the scenarios and then write how many states per scenario.

    For example 2 states per object for 16 objects is 32 states, or 2 states per combination of every pair of objects selected without replacemet is 2*16*15 = 480 or 512 if with replacement.

    This kind of thing would be a lot more informative and cause less confusion.
     
  5. Jul 16, 2012 #4
    I wrote a brute force program to solve the problem. By punching in the output of the brute forcing algorithm into WolframAlpha, I was able to find the sequence formula to solve this problem.

    An=C(2n,n)

    Code (Text):

    public class BruteForcePermutation {
       
        public static boolean countUniqueChar(int num, char symb, String text){
            int count = 0;
            int textLength = text.length();
            char[] charArray = new char[textLength];
           
            charArray = text.toCharArray();
           
            for(int i = 0; i<textLength; i++)
                if(charArray[i]==symb)count++;
           
            if(count==num) return true;
            else return false;  
        }
       
        public static String intToBinary(int num, int size){
            String result = "";
           
            while(num!=0){
                result = (num%2) + result;
                num /= 2;
                size--;
            }
           
            while(size>0){
                result = "0" + result;
                size--;
            }
           
            return result;
        }
       
        public static void main(String[] args){
            String currentBin = "";
            int permutations;
           
            int terms = 10;
            for(int size = 2; size<=terms*2;size+=2){
                permutations = 0;
                for(int i = 0; i<Math.pow(2,size) ;i++){
                    currentBin = intToBinary(i,size);
                    if(countUniqueChar((size/2),'1',currentBin)){
                        //System.out.println(currentBin);
                        permutations++;
                    }
                }
            System.out.print(permutations + " ");
            }
        }
    }
     
    I was working on this problem in particular in hope of creating a more efficient algorithm for a pathing problem.
     
  6. Jul 17, 2012 #5
    OK, so have you solved the problem to your satisfaction? If not, then could you please post a better description of your problem, because I don't want to read through Java to try to figure out what you mean.
     
  7. Jul 17, 2012 #6
    I am still unsure about how to determine the formula by observation.

    I'll try describing the problem differently.

    If you have a bag of n-Coins that contain (n/2) black coins and (n/2) white coins, how many ways can you place the white and black coins in a line of n?
     
  8. Jul 17, 2012 #7
    [tex]\binom{n}{n/2}[/tex]
    the number of combinations of n objects taken n/2 at a time.
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: Determining Combinations with Restraints
  1. Combinations - (Replies: 3)

  2. # of combinations (Replies: 6)

  3. Combination of Numbers (Replies: 2)

  4. Combination question (Replies: 1)

Loading...