title: Counting Overlaps of Integer Ranges
body: <p>I've been stumped on this algorithm for quite a bit.</p>
  
  <p>Say there are four ranges of integers.  Each range has a Start and an End value.</p>
  
  <pre><code>Range A: 0,5
  Range B: 4,12
  Range C: 2,10
  Range D: 8,14
  </code></pre>
  
  <p>From these values I would like to get a new set which counts of the number of the ranges that fall in a particular span of ints.  Each of these would have Start, End and Count values, producing something like this:</p>
  
  <pre><code>(Start, End, Count)
  0,1,1   (Only 1 range (A) falls between 0 and 1 inclusive)
  2,3,2   (2 ranges (A,C))
  4,5,3   (3 ranges (A,B,C))
  6,7,2   (2 ranges (B,C))
  8,10,3  (3 ranges (B,C,D))
  11,12,2 (2 ranges (B,D))
  13,14,1 (1 range (D))
  </code></pre>
  
  <p>Does that make sense?  What's a good way to approach the algorithm?</p>