How would go about doing this? I'm putting in 7 variables, but how would I make a loop where each variable was only used once and made every possible comination?

# Doing a cintunal math problem until solved

Started by Shadow Hatake, Mar 26 2006 09:06 PM

1 reply to this topic

### #1

Posted 26 March 2006 - 09:06 PM

### #2

Posted 26 March 2006 - 09:29 PM

[!--quoteo(post=358648:date=Mar 26 2006, 11:06 PM:name=Shadow Hatake)--][div class=\'quotetop\']QUOTE(Shadow Hatake @ Mar 26 2006, 11:06 PM) [/div][div class=\'quotemain\'][!--quotec--]

How would go about doing this? I'm putting in 7 variables, but how would I make a loop where each variable was only used once and made every possible comination?

[/quote]

I'm not totally sure what your problem is... You have seven variables and you want to do all combinations. The loop will be different if you consider (A and B) to be the same as (B and A) or not.

i.e

A*B == B*A but A-B != B-A

To create the loops your problem have to be more specified. All combinations can differ between two problems as you can see in the example abowe.

How would go about doing this? I'm putting in 7 variables, but how would I make a loop where each variable was only used once and made every possible comination?

[/quote]

I'm not totally sure what your problem is... You have seven variables and you want to do all combinations. The loop will be different if you consider (A and B) to be the same as (B and A) or not.

i.e

A*B == B*A but A-B != B-A

To create the loops your problem have to be more specified. All combinations can differ between two problems as you can see in the example abowe.

// A and B is the same as B and A for($i=0;$i<7;$i++) { for($j=$i;$j<7;$j++) { math between var[$i] and var[$j] } } // A and B is not the same as B and A for($i=0;$i<7;$i++) { for($j=0;$j<7;$j++) { math between var[$i] and var[$j] } }

--------------------------------------------------------------------------------------

I'm not stupid, I'm just unlucky while thinking.

----------------------------------------------------------------------------------------

I'm not stupid, I'm just unlucky while thinking.

----------------------------------------------------------------------------------------

#### 0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users