help with permutation problem
Dec 6, 2017 at 10:47am UTC
How can I find the number of permutation of different types of objects?
example: There is 5 walls. I have 5 cans of Yellow paint, 3 cans of Red paint and 2 cans of Blue paint.How many possible painting solutions do I have?
Dec 6, 2017 at 12:37pm UTC
181
1: YYYYY
2: RYYYY
3: BYYYY
4: YRYYY
5: RRYYY
6: BRYYY
7: YBYYY
8: RBYYY
9: BBYYY
10: YYRYY
11: RYRYY
12: BYRYY
13: YRRYY
14: RRRYY
15: BRRYY
16: YBRYY
17: RBRYY
18: BBRYY
19: YYBYY
20: RYBYY
21: BYBYY
22: YRBYY
23: RRBYY
24: BRBYY
25: YBBYY
26: RBBYY
27: YYYRY
28: RYYRY
29: BYYRY
30: YRYRY
31: RRYRY
32: BRYRY
33: YBYRY
34: RBYRY
35: BBYRY
36: YYRRY
37: RYRRY
38: BYRRY
39: YRRRY
40: BRRRY
41: YBRRY
42: RBRRY
43: BBRRY
44: YYBRY
45: RYBRY
46: BYBRY
47: YRBRY
48: RRBRY
49: BRBRY
50: YBBRY
51: RBBRY
52: YYYBY
53: RYYBY
54: BYYBY
55: YRYBY
56: RRYBY
57: BRYBY
58: YBYBY
59: RBYBY
60: YYRBY
61: RYRBY
62: BYRBY
63: YRRBY
64: RRRBY
65: BRRBY
66: YBRBY
67: RBRBY
68: YYBBY
69: RYBBY
70: YRBBY
71: RRBBY
72: YYYYR
73: RYYYR
74: BYYYR
75: YRYYR
76: RRYYR
77: BRYYR
78: YBYYR
79: RBYYR
80: BBYYR
81: YYRYR
82: RYRYR
83: BYRYR
84: YRRYR
85: BRRYR
86: YBRYR
87: RBRYR
88: BBRYR
89: YYBYR
90: RYBYR
91: BYBYR
92: YRBYR
93: RRBYR
94: BRBYR
95: YBBYR
96: RBBYR
97: YYYRR
98: RYYRR
99: BYYRR
100: YRYRR
101: BRYRR
102: YBYRR
103: RBYRR
104: BBYRR
105: YYRRR
106: BYRRR
107: YBRRR
108: BBRRR
109: YYBRR
110: RYBRR
111: BYBRR
112: YRBRR
113: BRBRR
114: YBBRR
115: RBBRR
116: YYYBR
117: RYYBR
118: BYYBR
119: YRYBR
120: RRYBR
121: BRYBR
122: YBYBR
123: RBYBR
124: YYRBR
125: RYRBR
126: BYRBR
127: YRRBR
128: BRRBR
129: YBRBR
130: RBRBR
131: YYBBR
132: RYBBR
133: YRBBR
134: RRBBR
135: YYYYB
136: RYYYB
137: BYYYB
138: YRYYB
139: RRYYB
140: BRYYB
141: YBYYB
142: RBYYB
143: YYRYB
144: RYRYB
145: BYRYB
146: YRRYB
147: RRRYB
148: BRRYB
149: YBRYB
150: RBRYB
151: YYBYB
152: RYBYB
153: YRBYB
154: RRBYB
155: YYYRB
156: RYYRB
157: BYYRB
158: YRYRB
159: RRYRB
160: BRYRB
161: YBYRB
162: RBYRB
163: YYRRB
164: RYRRB
165: BYRRB
166: YRRRB
167: BRRRB
168: YBRRB
169: RBRRB
170: YYBRB
171: RYBRB
172: YRBRB
173: RRBRB
174: YYYBB
175: RYYBB
176: YRYBB
177: RRYBB
178: YYRBB
179: RYRBB
180: YRRBB
181: RRRBB
Dec 6, 2017 at 2:22pm UTC
Sorry for not asking my question clearly. I mean I want to do this with C++.Can you suggest a alogthrim for me? Anyway thanks for your reply lastchance.
Dec 6, 2017 at 4:20pm UTC
I mean I want to do this with C++
I did do it with C++ !
Can you suggest a alogthrim for me?
OK - no idea if there's a better way, but this turned out to be very quick ... because I'd just written code for a related problem in a different thread.
Have a look at
http://www.cplusplus.com/forum/general/226281/#msg1032476
In that code you can simply change your "alphabet" (to "YRB") and the length of your "password" (to 5). This will give you ALL the 5-letter combinations of Y, R and B. Then you just have to write a short routine (mine was 6 lines) to check which are valid in the present problem - i.e. contain no more than 5 Y, 3 R and 2 B, which are the ones that you accept and count.
I trust that my interpretation of the problem is correct: one can of paint per wall and the walls are distinguishable.
Last edited on Dec 6, 2017 at 4:36pm UTC
Topic archived. No new replies allowed.