40
suic
16 39 57
9966/ 10664
Last seen 22 hours ago
Member for 9 years, 11 months, 3 days
Difficulty Advanced
Best reviews / Newest reviews
First-gregi87
Hi, a bit shoter version: def count_neighbours(grid, row, col): sg = lambda t: save_get(grid, row + t[0], col + t[1]) return sum(map(sg, ((-1,-1), (-1, 0), (-1, 1), (0, -1), (0, 1), (1, -1), (1, More
First-Victor.Mlnk
Hi, _min()_ and _max()_ are built-in functions. More
Small shit-zymtom
Or a big one? :D 1. Look at _extended slices_: `array[::2]` 2. _sum()_ built-in function: `sum(array[::2])` 3. You could write `i += 2` More
First-Victor.Mlnk
Hi, this a C-style solution. Try to look at _extended slices_ and _sum()_. More
dict and one-line function-waxdesf 1
Hi, actually those comments make it less readable. A few empty lines would make the thing. E. g.: # format odd items (n_:n_:n_) from len(4) to len(3) representation form = list(map(lambda x: x[1][1:] if not x[0]%2 else x[1], enumerate(mors))) # join hh, mm, ss, add ' : ', and remov More
Second-gunlinux 1
Hi, 1. You don't need that `lambda`. You can use _mul()_ from `operator` module or simply _int.\_\_mul\_\_()_. 2. You could use _map()_ and _str.replace()_ instead of that list comprehension: return reduce(int.__mul__ , map(int, str(number).replace("0", ""))) More
First-kleshmax 1
Hi, 1. look at _filter()_ and _str.join()_. 2. __str__ is immutable in Python, therefore is not the best type for accumulation. More
First-kleshmax 1
Hi, 1. look at _filter()_. 2. you could write `x += 1` More
First-kleshmax 1
Hi, look at _extended slices_ and _sum()_. More
First-gunlinux 1
Hi, you can use `*` for unpacking, e. g.: datetime.datetime(*date1) More
First-sake12
Hi, it would be faster and more memory efficient with _sum()_: count_words = lambda text, words: sum(w in text.lower() for w in words) More
Regex-sake12
Hi, that `regex` dictionary is redundant: regex = re.compile("[A-Z]") ... if regex.match(c): out += c In fact you don't need regex at all: return "".join(filter(str.isupper, text)) More
First-sake12
Hi, why not: return bool(re.search(r'([a-zA-Z]+) ([a-zA-Z]+) ([a-zA-Z]+)', words)) More
Simple and Clean-shui91
Clean? def checkio(array): return sum(array[::2]) * array[-1] if array else 0 More
First-007meena 1
Hi, forget about `;` in Python. Look at _sum()_ and _extended slices_. More
Don't know which one is the best-NEED 2
Hi, nice :) Can you do it without `if` and `try...catch`. More
First-nntndfrk 1
Hi, 1. you could import `ascii_uppercase` from `string`. 2. Instead of lines 8-11 you could write this: checks.append(item in text) 3. Or instead of 7-11 you could write: checks = [item in text for item in alphabet] 4. Instead of lines 12-14 look at _all()_: return all(checks) More
tricky-bbmin7b5
Hi, lot of redundancy there 1. that `if...else` is redundant: return len(password) >= 10 and match and match1 and match2 2. Or lines 4-6 contains the same pattern. More
Tricky!-bbmin7b5
Hi, that last if is redundant: `return ''.join(result)`. More
Compare sorted lists-NEED 1 1
Hi, if you have to use `\` there is something wrong :) return list.__eq__(*[[x for x in sorted(w.lower()) if x != " "] for w in (f, s)]) # :) More