summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Ward <peteraward@gmail.com>2014-06-28 08:28:06 +1000
committerPeter Ward <peteraward@gmail.com>2014-06-28 08:28:06 +1000
commitef8545d1fcdfb8a52e3094bc2a92a1e3850a08b4 (patch)
treec72c5db269a81d2c0d6e97fa5cf1d4eba3fec1c1
parentfe9b989f1836499bb8fada3ea99476834d75a9dd (diff)
parent79a1077fb7b2b4b978e9dec687ea86b195a0c407 (diff)
merged
-rw-r--r--average.py44
1 files changed, 44 insertions, 0 deletions
diff --git a/average.py b/average.py
new file mode 100644
index 0000000..01a98dc
--- /dev/null
+++ b/average.py
@@ -0,0 +1,44 @@
+from collections import defaultdict
+from itertools import imap as map
+from operator import itemgetter
+
+RESULTS_FILE = 'results.csv'
+results = defaultdict(list)
+
+for line in open(RESULTS_FILE, 'rU'):
+ game, name, length, time = line[:-1].split(',')
+ length = int(length)
+ time = int(time)
+ results[name].append((length, time))
+
+def average(items):
+ s = 0.0
+ l = 0
+ for item in items:
+ s += item
+ l += 1
+ return s / l
+
+lengths = []
+times = []
+
+for name, series in results.items():
+ length_average = average(map(itemgetter(0), series))
+ lengths.append((length_average, name))
+ time_average = average(map(itemgetter(1), series))
+ times.append((time_average, name))
+
+lengths.sort(reverse=True)
+times.sort(reverse=True)
+
+print 'Lengths'
+print '======='
+for length, name in lengths:
+ print name, length
+print
+
+print 'Times'
+print '====='
+for time, name in times:
+ print name, time
+