SOLUTION: C-program to get 35 combinations of the variables 'xxxxyyy'

Algebra.Com
Question 830568: C-program to get 35 combinations of the variables 'xxxxyyy'
Answer by Edwin McCravy(20054)   (Show Source): You can put this solution on YOUR website!
I don't know C.  I program in LibertyBASIC. I copied and pasted my 
LibertyBASIC program below for the 35 distinguishable 
permutations of xxxxyyy.  I think you can translate it to C 
using my comment statements which begin with ' followed by 4 spaces.
I copied and pasted my output below the program:
-----------------------------------------------------
'    start with xxxxxxx
gosub 1
'    choose leftmost position p to change an x to a y in
for p=1 to 5
'    choose a 2nd position q right of position p to change an x to y in
for q=p+1 to 6:if q=p then 2
'    choose a 3rd position r right of q to change an x to y in
for r=q+1 to 7:if r=q or r=p then 3
'    change the three x's to y's
a$(p)="y":a$(q)="y":a$(r)="y"
'    increase the count and print it
count=count+1:print count;". ";
'    print the first 6 letters in a row after the count
for s=1 to 6: print a$(s);:next s
'    print the 7th letter at the end the row
print a$(7)
'    change back to xxxxxxx
gosub 1
'    get the next value of r and loop back up
3 next r
'    get the next value of q and loop back up
2 next q
'    get the next value of p and loop back up
next p
'    we're done if we get here. So we end so we won't crash into the subroutine
end
'    subroutine to change all 7 to x's
1 for n=1 to 7:a$(n)="x":next n:return

---------------------------------------------
Here is the output for the above LIBERTY BASIC program
1. yyyxxxx
2. yyxyxxx
3. yyxxyxx
4. yyxxxyx
5. yyxxxxy
6. yxyyxxx
7. yxyxyxx
8. yxyxxyx
9. yxyxxxy
10. yxxyyxx
11. yxxyxyx
12. yxxyxxy
13. yxxxyyx
14. yxxxyxy
15. yxxxxyy
16. xyyyxxx
17. xyyxyxx
18. xyyxxyx
19. xyyxxxy
20. xyxyyxx
21. xyxyxyx
22. xyxyxxy
23. xyxxyyx
24. xyxxyxy
25. xyxxxyy
26. xxyyyxx
27. xxyyxyx
28. xxyyxxy
29. xxyxyyx
30. xxyxyxy
31. xxyxxyy
32. xxxyyyx
33. xxxyyxy
34. xxxyxyy
35. xxxxyyy

Edwin

RELATED QUESTIONS

.The programmer, Sammy plans to mark up the price of his virus program 35% whereas the... (answered by stanbon)
The profit, P, from a computer program is related to the cost, C, of developing the... (answered by josmiceli)
How many different sets of 4 marbles can you package if you have blue, white, yellow and... (answered by ewatrrr)
The number of squares that can be formed on a chess board is-: a)204 b)304 c)1296... (answered by KMST)
Find the number of ways to get the following card combinations from a 52-card deck. Two... (answered by stanbon)
Can someone pleas help me solve this math problem, thank you. Suppose that in one... (answered by mananth)
Find the number of combinations C 6... (answered by solver91311)
Suppose probability of a person to have type AB is 6%. Pick 5 people at random then... (answered by Fombitz)
jenna picks 30 cds to play from a collection of 35 how many different combinations of the (answered by richwmiller)