title: Finding how many elements from a list you need to reach a certain percentage coverage
body: <p>I have a long list x = [4,6,7,8,8,8,9,0,9,1,7,7]
  I know I can use counter to see how many times an item appears.</p>
  
  <pre><code>x = [4,6,7,8,8,8,9,0,9,1,7,7]
  from collections import Counter
  Counter(x)
  
  &gt;&gt;Counter({0: 1, 1: 1, 4: 1, 6: 1, 7: 3, 8: 3, 9: 2})
  </code></pre>
  
  <p>I can sort them using:</p>
  
  <pre><code>Counter(x).most_common()
  
  &gt;&gt;Counter(x).most_common()
  Out[33]: [(7, 3), (8, 3), (9, 2), (0, 1), (1, 1), (4, 1), (6, 1)]
  </code></pre>
  
  <p>Now, I want to know how many elements I need to cover 50% of my list. For example, 7 and 8 appear 6 times, there are 12 elements, so I only need 7 and 8 to cover 50% of the elements in the list. If I add 9, I have 8 elements, so 7, 8 and 9 cover 66% of the elements in the list.</p>
  
  <p>If my list has hundreds of thousand of elements, how do I do that?</p>