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
Suurballe algorithm-macfreek 1
Interesting code, but huge :) That's why I dislike objects. Look at http://www.checkio.org/mission/snake/publications/blabaster/python-3/autious-approach-2/ And last, but not least: assert check_solution(checkio, ['...T10.T..', '.T..2T...T', More
First-ciel 1
if len(stack): # no! if stack: # unpythonic: empty iterable returns False More
First-pohmelie 1
curr_throw = collections.defaultdict(lambda: 0) # no! curr_throw = collections.defaultdict(int) # better curr_throw = collections.Counter() # best # so on new_units = collections.defaultdict(lambda: 0.0) # no! new_units = collections.defaultdict(float) d = More
Double caching-Talim42 1
if u1 < 1 or prob < 1/1e6: # ignore such small chances Heh, hard way. This task can be resolved by max(units_1, units_2) steps (or less). Look at http://www.checkio.org/mission/battle-dice/publications/blabaster/python-3/first/, line 21, it shows how to cut idle forks. More
First-meianki
s_col = [sum(r) for r in zip(*matrix[:])] zip() doesn't damage args, so "[:]" redundant. More
First-gabilloillo 1
if len(letter) != 0: # no! if not letter: # empty iterable (ie list, set, string) # returns False (if checked as bool) More
First-ciel
Cycle of filling a matrix looks a bit cumbersome. 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
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
First-gyahun_dash 1
1. Why recursion? Strange :) 2. "floor", "ceil" - names from math namespace. "lo" and "hi" looks more reasonable. 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-admiral_proton
Is it really necessary to sort twice? More
around-veky 1
... functions and method calls are expensive (more so than in C or Java) ... /by Guido/ More
lru_cache-gyahun_dash 1
gun = tuple( tuple(map(int, s)) for s in ('000000000000000000000000100000000000', '000000000000000000000010100000000000', '000000000000110000001100000000000011', '000000000001000100001100000000000011', '110000000010000010001100000000000000', '11000000001000101100 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
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-andrea.manno1 1
((1,2),(2,1))[row%2][col%2] Too heavy for my mind (rown + coln) % 2 + 1 :=)) 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-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-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