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-daswerth
You like typing :) import re VOWELS = "[AEIOUY]" CONSONANTS = "[BCDFGHJKLMNPQRSTVWXZ]" r = re.compile(r'\A({0}?({1}{0})*{1}?){2}\Z'.format(VOWELS, CONSONANTS, '{1}'), re.I) def checkio(text): return sum(bool(len(w) > 1 and r.match(w)) for w in re.split(r' More
First-daswerth
Hi, instead of lines 14-17 you could write: return brackets == [] # or return not brackets More
First-joelhoward0
Hi, this is "obfuscative". Why not: return [d for d in data if data.count(d) > 1] # ? More
First-tehtactics19
Hi, without `string` it would be nicer. More
First-tehtactics19
Hi, [] are redundant. Look at _filter()_ built-in function. More
First-tehtactics19
Hi, `if x == '0': continue` is redundant. Why not: if not x == '0': count *= int(x) More
First-tehtactics19
Hi, `len(array)` is redundant. More
First-tehtactics19
Hi, that `else: print str(number)` is redundant. More
First-Rita 1 1
Hi, 1. Instead of `t == t.upper()` you could use `t.isupper()` With _str.isupper()_ you can omit the `t.isalpha()` check. 2. `t` is already __str__ so _str()_ on lines 4 and 5 is redundant. result += t 3. Look at _filter()_ built-in. 4. __str__ is immutable type, therefore is not the best jo More
First-Rita 1
Hi, 1. Look at _sum()_ built-in function. 2. Lines 9-20 are redundant. More
First-Jalk65
Hi, 1. Why not?: if len(array) > 0: # or even: if array: # and: for i in array[::2]: # instead of for i in array[0: len(array): 2]: 2. Look at _sum()_: # sum of even elements: sum(array[::2]) More
Back to front-puay
Hi, 1. Look at _divmod()_. 2. Look at [this](https://docs.python.org/3.4/library/stdtypes.html#truth-value-testing). def checkio(number): multiple=1 while number: number, digit = divmod(number, 10) if digit: multiple *= digit return multiple More
First-puay
Hi, _bin()_ return __str__ so `str(bin_num)` is redundant. As `bin(number)` is a __str__ you can use _str.count()_ method. More
First-eugene128736871
Hi, have you heard about extended slices? More
First-eugene128736871
Hi, 1. _max()_ and _dict()_ are a built-in functions. 2. Look at _sorted_, e. g.: `alpha = sorted(dict)` 3. Even if Python's exceptions are not expensive, lines 2-9 are quite ugly. 4. Look at __collections.Counter__. I've played with your code. Result is [here](http://www.checkio.org/mission/most- More
First-eugene128736871
Hi, it's kinda verbose: 1. `== None` is redundant. 2. You can use _all()_ instead of those `if`s. 3. In each if condition you have the same pattern. return all(re.search(rgx, d) for rgx in ("^.{10,}$", "[0-9]+", "[a-z]+", "[A-Z]+")) More
First-eugene128736871
Hi, you can shorten it: return sum(z in text.lower() for z in words) More
First-eugene128736871
Hi, [] are redundant. Look at _filter()_. More
First-eugene128736871
Hi, it's inefficient, and not as clear as it could be: return "".join(phrases).replace('right', 'left') More
First-eugene128736871
Hi, don't use `sum` for variable names. It's a built-in function. More