17
Khan Ag
Last seen 5 months ago
Member for 7 years, 10 months, 14 days
Difficulty Normal
U dont have to calculate len of intersection of sets. Read a formula in this article: [wikipedia](https://en.wikipedia.org/wiki/Inclusion%E2%80%93exclusion_principle)
More
Use getattr built-in function.
For example: getattr(hashlib, "md5") -> hashlib.md5
More
if u write
if i == True: return True
, shouldn't it work?
less condition checking in the loop -> faster
More
You should use built-in function called "len" instead of calculate it manually. Example:
len([1, 2, 3]) retrieves 2.
More
Nice trick with fucntools.partial. Haven't know 'bout it
More
Look at this method:
https://docs.python.org/2/library/stdtypes.html#str.zfill
More
Creating a dict to check coordinates being in bounds? Isn't it faster to just check coordinates? like 0<=xMore
if u used this, it would be easier:[python docs](https://docs.python.org/3.2/library/functools.html#functools.lru_cache)
More
I just realised that, pow(n, True, i) == n % i
This is awesome, man :D
More
for j, another in enumerate(words):
if i != j:
sumlikeness += calculate_likeness(word, another
instead of calc it the C way, use sum fucntion.
More
use count method of string instead. and why do u use str() on bin returned value? bin returns str type
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
not very fast, mine is faster :D
Checked with timeit for 19 rings:
12.9365308285 43.1890509129
More