title: How to find the biggest common range?
body: <p>I have a list of hundreds of tuples like this:</p>
  
  <pre><code>list1 = [(epoch1, epoch2), (epoch3, epoch4), (epoch5, epoch6)]
  </code></pre>
  
  <p>every tuple contains the  beginning  and the end of the session in a form of an epoch.  </p>
  
  <p>What I want to find is  the maximum number of sessions that occurred at the same time. So if <code>epoch1 = 16:00, epoch2=16:30, epoch3=16:15, epoch4=16:45, epoch5=18:00, epoch6=19:00</code>, the answer would be <code>2</code>, because from <code>16:15 to 16:30</code> there were two sessions active (the first one and the second one).</p>
  
  <p>I thought that one way to do this is to create a new list containing all the dates like this:</p>
  
  <pre><code>list2 = [epoch1, epoch2, epoch3, epoch4, epoch5, epoch6]  
  </code></pre>
  
  <p>Then iterate through every pair of elements in <code>list2</code> and check for how many of <code>list1</code> tuples contains them in its session borders. But I suppose this solution is very slow. Does anyone have other ideas?</p>