Learn

When enumerating a multiset, we are sometimes interested in the relative order of some members of the set. Take for example the problem of figuring out how many ways we can order the letters in the word APPLE such that the two P’s appear next to one another (ELPPA for example). The set of letters in this problem is S = {A, P, P, L, E} which is a set of cardinality five. Since we want the two P’s together, we can treat them as a single element PP. The set now looks like this: S = {A, PP, L, E} of cardinality four. We would enumerate this using the same technique as we did in Exercise 2 to obtain an answer of:

$4! = 24$

There are 24 possible permutations of the word APPLE in which the two P’s are next to one another.

### Instructions

1.

A box contains three red balls, three blue balls, and three green balls. How many ways can you arrange the nine balls such that you have two red balls and one green ball appearing together? Assume initially that each color is distinct. Set the variable nine_balls_1 to your answer.

2.

All balls of the same color are not distinct! How would you correct your previous calculation to account for this fact? Set the variable nine_balls_2 to your answer.