Calculating possible combinations

Mathematics and Science; the subtle and ubiquitous arts

Calculating possible combinations

Post by Amidda1217 on Tue Jul 27, 2010 8:46 am
([msg=42820]see Calculating possible combinations[/msg])

I know this can probably be done via factorial. But it has been a long time and I have forgotten how to do it.

If you have 2 variables x and y of two sets. So x1 x2 y 1 y2 and you want to test all possible combinations of > = <. How do you calculate the possible number of combinations?

x1 > y1 and
x2 > y2

x1 < y1 and
x2 < y2

X1 >y1 and
x2 < y1

x1 < y1and
x2 >y1

x1 = y1and
x2 = y2

x1 > y1and
x2 = y2

and so on...
The user can't be patched.
Amidda1217
New User
New User
 
Posts: 31
Joined: Thu Jun 04, 2009 6:49 am
Blog: View Blog (0)


Re: Calculating possible combinations

Post by cilpolir on Fri Jul 30, 2010 11:36 am
([msg=42990]see Re: Calculating possible combinations[/msg])

I would say X1 can be <,= or > to Y1, sot that are 3 combinations, X1 can also be that to y2 so that is 3*3 combinations, repeating this for x2 gives 3^4 combinations
edit:
I wrote a code in c to write down al combinations and count them, here's the code:
Code: Select all
#include <stdio.h>
#include <stdlib.h>

int main()
{
    char signs[3];
    char sign1,sign2,sign3,sign4;
    int a,b,c,d;
    int combination;
    FILE *fp;

    fp=fopen("test.txt","w");

    signs[0]='>';
    signs[1]='=';
    signs[2]='<';

    combination=0;

    for(a=0;a<3;a++)
    {
        for(b=0;b<3;b++)
        {
            for(c=0;c<3;c++)
            {
                for(d=0;d<3;d++)
                {
                    sign1=signs[a];
                    sign2=signs[b];
                    sign3=signs[c];
                    sign4=signs[d];
                    fprintf (fp, "x1 %c y1\nx1 %c y2\nx2 %c y1\nx2 %c y2\n\n",sign1,sign2,sign3,sign4);
                    combination++;
                }
            }
        }
    }
    fprintf (fp, "there is a total of %d combinations",combination);
    fclose (fp);
    return 0;

}
Image
User avatar
cilpolir
Poster
Poster
 
Posts: 214
Joined: Sat Sep 12, 2009 10:46 am
Blog: View Blog (0)


Re: Calculating possible combinations

Post by msbachman on Fri Jul 30, 2010 7:39 pm
([msg=43006]see Re: Calculating possible combinations[/msg])

This sounds like a homework question.

@ the OP: what are YOUR ideas about how to calculate the possible combinations?

Give the forum something to show you've done some work on this issue on your own. That said, clipolir's response was very helpful.

@ Clipolir:

If you like solving problems like that, check out freelancer.com. That way you can help people and make some money, instead of helping people and having them take advantage of you. I think the latter is in play here.

-- Fri Jul 30, 2010 7:42 pm --

Case in point:

Amidda1217 wrote:I know this can probably be done via factorial. But it has been a long time and I have forgotten how to do it.


So, what the OP is basically saying is this:

...I've forgotten how to do it...and since my time is worth so much more than everyone else's, I'll post it onto the HTS forums for someone else to bother with it.

I can't be bothered to put forth effort to solve my own problems. Someone, solve this for me and I'll get to it when it's convenient for me.


I'm not saying that the OP isn't worth the help, it's just that at this point there's not much to evidence that he/she worked hard at solving it independently before asking us. If "factorials" were an answer to this issue (I'd like to see how they are, btw), then they don't need our help. They already have the answer. The work is up to them.
"I'm going to get into your sister. I'm going to get my hands on your daughter."
~Gatito
User avatar
msbachman
Contributor
Contributor
 
Posts: 681
Joined: Mon Jan 12, 2009 10:22 pm
Location: In the sky lol
Blog: View Blog (0)



Return to Math & Science

Who is online

Users browsing this forum: No registered users and 0 guests