40
suic
16 39 57
9964/ 10664
Last seen 4 days ago
Member for 9 years, 10 months, 19 days
Difficulty Advanced
Best reviews / Newest reviews
First-artemoniux
Hi, 1. Why not `str(number)` instead of `string='{}'.format(number)`. 2. I'm sorry but, lines 5-7 are so funny :) for i in string: if not i == '0': result *= int(i) # or even: for i in str(number): if not i == '0': result *= int(i) 3. Look at More
First-pavelnenov
Hi, you don't need the ...if..else: return re.match("^(?=.*[a-z])(?=.*[A-Z])(?=.+[0-9]).{10,}$",data) # or if you want: return bool(re.match("^(?=.*[a-z])(?=.*[A-Z])(?=.+[0-9]).{10,}$",data)) More
Using set -caynan 1
Hi, the last if is redundant: return length >= 10 and contains_lower and contains_upper and contains_digit If data is to short you don't need to continue: if len(data) < 10: return False etc. Shortened version: def checkio(data): if len(data) < 10: return False More
First-talha.zaman 1
One-liner: checkio = lambda data: len(data) >= 10 and all(map(set(data).__and__, map(set, (string.ascii_lowercase, string.ascii_uppercase, string.digits)))) More
First-artemoniux
Hi, `string` and `result` are redundant. You can chain methods in Python: return ','.join(phrases).replace('right','left') More
First-artemoniux
Hi, __bool__ is subtype of __int__ in Python, Therefore all the nested `if..else` statements are redundant e. g.: if O == c: R = x and y elif O == d: R = x or y More
First-artemoniux
Hi, you could use _enumerate()_. More
First-artemoniux
Hi, you could unpack `date1` and `date1` with `*` e. g.: date_1 = datetime.date(*date1) and `d` is redundant: return abs(date_2 - date_1) More
First-plane
Hi, look at extended slices: sum(array[::2]) More
Perhaps a bit overcomplicated?-NerdAlert1101
Hi, 1. Creative? 2. That elif...else is redundant. More straightforward approach would be better here. 3. First if is redundant. See the preconditions. More
First-LukeMurray
Hi, 1. the last if is redundant. 2. Once an if condition is met, you can continue. E. g.: if char.isdigit(): digitCount += 1 continue 3. You can move the last if inside the loop: for ...: ... if digitCount > 0 and upperCount > 0 and lowerCount > 0: More
First-evdel
Hi, you can use `sorted` instead of sort: return ','.join(sorted(new)) More
First-evdel
Hi, `line` is redundant: return ','.join(phrases).replace('right', 'left') More
First-evdel
Hi, all the `if`s inside `if`s are redundant. E. g.: if o == N[3]: reutrn x != y More
First-LukeMurray 1
Hi, 1. Don't use _max_ as variable name. _max()_ is a useful built-in function. 2. Look at collections.Counter. More
First-LukeMurray 1
Ugh... this is so repetitive. Shortened: def checkio(n): nums = (('M',1000), ('CM',900), ('D',500), ('CD',400), ('C',100), ('XC',90), ('L',50), ('XL',40), ('X',10), ('IX',9), ('V',5), ('IV',4), ('I',1)) More
First-evdel
Hi, 1. All the `== True` are redundant. 2. The last `if` is redundant. 3. When `data` is too short, you don't need the for loop, you can immediately return. if len(data) < 10: return False More
First-evdel
Hi, the last if is redundant: return len(al) >= 26 More
Two-liner, short, universal-AntoniGoldstein
Hi, 1. Why two-liner and why c? return ' '.join(sum(((v,) for k,v in {3: 'Fizz', 5: 'Buzz'}.items() if number % k == 0),())) or str(number) 2. Why _sum()_? return ' '.join(v for k, v in {3: 'Fizz', 5: 'Buzz'}.items() if number % k == 0) or str(number) 3. Why not one-liner? check More
First-artyomushko
Hi, those `bool`s are redundant. More