You are viewing a single comment's thread. Return to all comments →
Nice but you're iterating 3 times:
A classical solution could be faster
In [7]: def f1(a,b): ...: score = [1 if x > y else 0 if x == y else -1 for x, y in zip(a, b)] ...: ...: (score.count(1), score.count(-1)) ...: In [8]: %timeit f1(a,b) 100000 loops, best of 3: 13.4 µs per loop In [11]: def f2(a,b): ...: s1,s2=0,0 ...: for x,y in zip(a,b): ...: if x>y: s1 += 1 ...: elif y<x: s2+= 1 ...: ...: In [12]: %timeit f2(a,b) 100000 loops, best of 3: 9.18 µs per loop
Seems like cookies are disabled on this browser, please enable them to open this website
Compare the Triplets
You are viewing a single comment's thread. Return to all comments →
Nice but you're iterating 3 times:
A classical solution could be faster