Counting intersections for all combinations in a list of sets
<p>I have a collection of sets. I want to find the number of items that are found only in the intersection for each combination of sets. I'm basically want to do the same thing as creating the numbers in a Venn diagram.</p>

<p>An basic example might make it clearer.</p>

<pre><code>a = set(1,2,5,10,12)
b = set(1,2,6,9,12,15)
c = set(1,2,7,8,15)
</code></pre>

<p>I should end up with a count of items found only in:</p>

<ul>
<li>a</li>
<li>b</li>
<li>c</li>
<li>the intersection of a and b</li>
<li>the intersection of a and c</li>
<li>the intersection of b and c</li>
<li>the intersection of a, b and c</li>
</ul>

<p>A non-extensible way of doing this is</p>

<pre><code>num_a = len(a - b - c)  # len(set([5,10])) -&gt; 2
num_b = len(b - a - c)  # len(set([6,9])) -&gt; 2
num_c = len(c - a - b)  # len(set([7,8])) -&gt; 2

num_ab = len((a &amp; b) - c)  # 1
num_ac = len((a &amp; c) - b)  # 0
num_bc = len((b &amp; c) - a)  # 1

num_abc = len(a &amp; b &amp; c)  # 2
</code></pre>

<p>While this works for 3 sets my collection of sets is not static.</p>
