Code question - Creating table of combinations

General Intelligent Discussion & One Thread About That Buttknuckle

Moderator: Andrew

Code question - Creating table of combinations

Postby Memorex » Wed Nov 09, 2011 12:22 pm

I'm working on something and I can't quite figure it out. Hoping someone here can provide an answer. Mathematics goes with Melodic Rock, right?

So I have 9 groups of value. Let's say there are two values (A & B) in each group. I need to create a table of all the possible combinations.

I do not want to use both A and B from any of the groups in the same combination and I must have at least one value from each group. Example:

Group 1 a & b
Group 2 a & b
Group 3 a & b
etc...

The first group would be [a a a a a a a a a]. The second group might be [a b a a a a a a a].

Obviously I'd like to put this into some kind of loop. For the table, I can write each letter on a separate row, as long as I have some other value in a column that identifies all nine rows as a combination.

Hope that made sense. Thanks in advance if you know how to help.
User avatar
Memorex
Stereo LP
 
Posts: 3570
Joined: Sat Jun 24, 2006 1:30 pm

Re: Code question - Creating table of combinations

Postby S2M » Wed Nov 09, 2011 12:26 pm

Memorex wrote:I'm working on something and I can't quite figure it out. Hoping someone here can provide an answer. Mathematics goes with Melodic Rock, right?

So I have 9 groups of value. Let's say there are two values (A & B) in each group. I need to create a table of all the possible combinations.

I do not want to use both A and B from any of the groups in the same combination and I must have at least one value from each group. Example:

Group 1 a & b
Group 2 a & b
Group 3 a & b
etc...

The first group would be [a a a a a a a a a]. The second group might be [a b a a a a a a a].

Obviously I'd like to put this into some kind of loop. For the table, I can write each letter on a separate row, as long as I have some other value in a column that identifies all nine rows as a combination.

Hope that made sense. Thanks in advance if you know how to help.


Would a Punnett Square help?

Image
Tom Brady IS the G.O.A.T.
User avatar
S2M
MP3
 
Posts: 11981
Joined: Mon Jun 02, 2008 4:43 am
Location: In a bevy of whimsy

Postby Memorex » Wed Nov 09, 2011 12:32 pm

Would that only get me all the possible combinations of 2 numbers, including 2 from the same group. Not sure how this works. But in my case, each combination must have nine values, one item from each group (a or b).
User avatar
Memorex
Stereo LP
 
Posts: 3570
Joined: Sat Jun 24, 2006 1:30 pm

Postby S2M » Wed Nov 09, 2011 12:38 pm

Memorex wrote:Would that only get me all the possible combinations of 2 numbers, including 2 from the same group. Not sure how this works. But in my case, each combination must have nine values, one item from each group (a or b).



Yes...put the first group vertical(like the blue string in my photo)...then put the 2nd group horizontal(like the pink group in the photo).

Then fill in the blank squares with the combinations....
Tom Brady IS the G.O.A.T.
User avatar
S2M
MP3
 
Posts: 11981
Joined: Mon Jun 02, 2008 4:43 am
Location: In a bevy of whimsy

Postby Memorex » Wed Nov 09, 2011 1:05 pm

I'm sorry - feel like a dunce here - I'm not sure which two groups you mean.
User avatar
Memorex
Stereo LP
 
Posts: 3570
Joined: Sat Jun 24, 2006 1:30 pm

Postby S2M » Wed Nov 09, 2011 1:15 pm

Memorex wrote:I'm sorry - feel like a dunce here - I'm not sure which two groups you mean.


From your first post:

The first group would be [a a a a a a a a a]. The second group might be [a b a a a a a a a].
Tom Brady IS the G.O.A.T.
User avatar
S2M
MP3
 
Posts: 11981
Joined: Mon Jun 02, 2008 4:43 am
Location: In a bevy of whimsy


Return to Snowmobiles For The Sahara

Who is online

Users browsing this forum: No registered users and 5 guests