27
blabaster
10 27 36
4095/ 4195
Last seen 3 months ago
Member for 10 years, 4 months, 9 days
Difficulty Normal
Best reviews / Newest reviews
Dynamic programming-Sim0000 2 1
if n1 == 0 or n2 == 0: return n1 + n2 More
Simple DP Levenshtein-Lipen 1
>>> False == 0 True >>> True == 1 True so line№16 looks excessive More
ShellSort_Median-PoveSW 1
if len(data) % 2 is 0: No! First, the results of this "is" comparison with with "calculated objects" are undefined (depends on compiler). On Cpython it works, because it keeps **some small integers** in pull, but this is a derty hack. The only legal and recommended "reserved" argument for "is" More
MAPING numerals-spoty
What about divmod: for integer, numeral in MAP: count, n = divmod(n, integer) r.append(numeral * count) return ''.join(r) More
First-gethappy 1
If you don't need item, don't pop it - del is faster. More
First-jcg
>Martin GARDNER Excactly >>> math.exp(1) == math.e True More
First-Blastus 1
def area(self): north = self.south + self.width_NS east = self.west + self.width_WE return (north - self.south) * (east - self.west) a bit confusing ;) More
First-frichard44
... explicit is better than implicit ... It's a Hell: self.connections = set() for con in connections: self.add(con) How to relate self and self.connections? I urge python's guru. More
First-Quandray 1
# line №5: grid = list(map(list, crossword)) # lines №№133..138: return tuple(map(''.join, grid)) # It's a python ;) More
First-andrea.manno1 1
((1,2),(2,1))[row%2][col%2] Too heavy for my mind (rown + coln) % 2 + 1 :=)) More
First-andrea.manno1 1
Every python's object returns True or False, if you ask ;) For numbers - zero returns False, for list or dict (etc) empty returns False ie x = 777 if x: # True pass More
First-Termaji 1
What about style? lines 15..16 - chain assignment: p = r = 0 lines 17, 19, 39 - redundant brackets: while p < lm: lines 23, 24, 25, 26, 43, 45 - increment: p += tmp And, of course: def f(r, c): return (r + c) % 2 + 1 One more advice: http://pep8online.com/ More
literally Counter-veky 1
Replace {-1,0,1} on (-1,0,1) -> speedup 10% with no extra chars ))) More
lru_cache-gyahun_dash 1
gun = tuple( tuple(map(int, s)) for s in ('000000000000000000000000100000000000', '000000000000000000000010100000000000', '000000000000110000001100000000000011', '000000000001000100001100000000000011', '110000000010000010001100000000000000', '11000000001000101100 More
ChickenHunt-bunnychai 1 2
To chase the reflection - perfect. Final checks sometimes fails: while True: assert checker(hunt, ('.....X..', '.X.XXX..', '....X...', '.X.XXX..', '..X..X..', More
around-veky 1
... functions and method calls are expensive (more so than in C or Java) ... /by Guido/ More
buble_sorted-brlm.franke
Bubble seems a good idea, but really not: the same number of comparisons (as most common algo) plus useless swaps. A bit about codestyle: list2=[] for i in sequence: list2.append(i) # shorter: list2 = list(sequence) ... for i in r More
First-ciel
Cycle of filling a matrix looks a bit cumbersome. More
First-admiral_proton
Is it really necessary to sort twice? More
First-freeman_lex 1
elif i == "POP" and len(A): sum+=A.pop() elif len(A): sum+= A[-1] Add a bit of elegance: else: if A: sum += A.pop() if i == "POP" else A[-1] and name var as a "sum" is a bad practice :( More
1
2 3