1. ## counting sets

I own twenty-three programming textbooks. Nine of them cover Java, ten cover Python, and ten cover C++. Three cover Java and C++, one covers Python and C++, and two cover Python and Java. How many cover only Python?

2. This can be solved using Inclusion–exclusion principle (IEP). Let us denote the sets of books covering each language as J, P, and C. The set of all books is $\displaystyle J\cup P\cup C$, though these three sets intersect invarious ways. By IEP,

$\displaystyle |J\cup P\cup C|=|J|+|P|+|C|-|J\cap P|-|J\cap C|-|P\cap C|+|J\cap P\cap C|$

You know the left-hand side and all but the last term in the right-hand side, so you can find the last one.

Next, Let $\displaystyle PO$ be the set of books about Python only. Then $\displaystyle P=PO\cup (P\cap C)\cup (P\cap J)$. Again we have the union of three sets. Apply IEP to this union. This will allow you to find $\displaystyle |PO|$.

It may also help looking at the three-set diagram on the Wikipedia page given above.

3. Thanks that really helped.