Created
March 3, 2010 10:38
-
-
Save pervognsen/320514 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def all_equal(iterable): | |
it = iter(iterable) | |
try: | |
first = it.next() | |
return all(x == first for x in it) | |
except StopIteration: | |
return True | |
def median(seq, key=None): | |
sorted_seq = sorted(seq, key=key) | |
return sorted_seq[len(seq) / 2] | |
def partition(seq, pivot, key=lambda x: x): | |
left, middle, right = [], [], [] | |
for x in seq: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment