17
Khan Ag
Last seen 5 months ago
Member for 7 years, 10 months, 28 days
Difficulty Normal
I used same logic. But forgot about i can extract the "1/2" out of sum :)
More
checked it with timeit, runs faster then first implementation 4 times :)
input:
print timeit.timeit("checkio(random.sample(xrange(10000), 1000))", number=1000, setup="from __main__ import checkio; import random"), \
timeit.timeit("checkio2(random.sample(xrange(10000), 1000))", number=1000, s
More
not very fast, mine is faster :D
Checked with timeit for 19 rings:
12.9365308285 43.1890509129
More
It won't work if you change some of the attributes. I'm talking about self.east and self.north
More
It's not pythonic. Better not use counters and this kind of stuff u use in c/c++ or java.
More
instead of:
while t.replace(' ', ' ') != t:
t = t.replace(' ', ' ')
you could use:
re.sub(' +', ' ', text)
More
if len(args)==0: and if args: is the same, because in python all empty list, dicts etc. means False.
More
Better use slicing for it. Like this: array[::2]. First two parameters are for begin and end indexes. If you want whole list, you don't touch it (for example [1,2,3][:] will retrieve the same list). Third parameter is for "step". For array=[0,1,2,3,4,5] it will retrieve [0,2,4].
More
Better use generator instead of creating a list for loops. Because u iterating two times, first when you create list, then inside of loop. It is slower 2 times. Just change [] to () and you will not create a list, just iterate over it.
More