Skip to content

Instantly share code, notes, and snippets.

@liuyuuan
Created March 23, 2013 16:46
Show Gist options
  • Select an option

  • Save liuyuuan/5228379 to your computer and use it in GitHub Desktop.

Select an option

Save liuyuuan/5228379 to your computer and use it in GitHub Desktop.
import sys
def count(recs, delimiters):
recs.sort()
delimiters.sort()
c = 0
result = []
for i in recs:
if len(delimiters):
if i <= delimiters[0]:
c += 1
else:
result.append([c, delimiters.pop(0)])
while len(delimiters) and i > delimiters[0]:
result.append([c,delimiters.pop(0)])
return result
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment