summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes Weiner <hannes@cmpxchg.org>2012-01-20 15:30:45 +0100
committerJohannes Weiner <hannes@cmpxchg.org>2012-01-20 15:30:45 +0100
commit1f526ad520db8dcafd4e8e29130b182c450f5cf5 (patch)
tree3c7cd3bfbcb7fa7b79a4852945010b3ed8ce90e8
parentff0d8d374a1272fdff5cc8dd7bb929f43ba001a2 (diff)
median: fix off-by-one
Who would have thought list indexes start at 0? Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>
-rwxr-xr-xmedian2
1 files changed, 1 insertions, 1 deletions
diff --git a/median b/median
index c6832dc..f82fbc8 100755
--- a/median
+++ b/median
@@ -14,7 +14,7 @@ def median_sorted(v):
if l % 2:
return v[m]
else:
- return mean([v[m], v[m + 1]])
+ return mean([v[m - 1], v[m]])
parser = argparse.ArgumentParser()
parser.add_argument('-m', '--minmax', action='store_true')