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
Second-zongareight 1 1
This will evaluate everything before it's checked with `any()`. It can be avoided by chaining `or`s. More
Recursion sum-Alexander_Antonov
Shorter alternative: ```python def checkio(data, s=0): return data and checkio(data, s + data.pop()) or s ``` More
First-yuwai
`from import *` is not a good practice in general and there's no good reason reason to use this as you use only a class a function from that module. Regards, suic More
7-liner-przemyslaw.daniel
Alternative: ```python def convert(n, d, f=__import__('itertools').product, r=range(1, 100), s=__import__('re').sub, q= __import__('decimal')): q.getcontext().prec = 100 k, p = str(q.Decimal(n)/d).replace('.', ''), str(n/d).find('.') for a, b in [(k[:x], k[x:][:y]) for x, y in f(r, r) if More
First-aya.kanazawa 1 1
Alternatives: 32.-33. self.units.extend(ones_class() for _ in range(number)) 35.-39. def is_someone_alive(self): return any(one.is_alive for one in self.units) More
First-denys.contant
Hi, `if all(digit in possible for digit in number):` is a shorter alternative for line 5. Regards, suic More
Second-colinmcnicholl 1 1
Hi, here's a bit shorter alternative: ```python import string def checkio(str_number, radix): d = dict(zip(string.digits + string.ascii_uppercase, range(36))) decimals = [d[num] for num in str_number] if radix <= max(decimals): return -1 return sum(dec * radix ** (l More
First-vovoka
Hi, I finally found a solution which doesn't use exceptions. However, this is quite inefficient: 1. `str_number = str_number[1:]` creates unnecessary intermediate strings. `for` loop is the preferred way to iterate over an iterable including `str`. 2. No 1. is actually needed because of `len(str_nu More
First-alexandrov.net 1
Alternative for 28-29.: `self.stuff.extend(unit() for i in range(amount))` More
Sets-Pouf 1 1
You can avoid the conversion to list on line 6 with ```python power_plants = {next(iter(n-{i})): power_plants[i]-1 for n in network ``` Regards, suic More
First-Vasily__Chibilyaev 1 1
Very nice! IMO lines 7-9 would be more readable this way: ```python s |= { n1 if c==n2 else n2 for c in s for n1, n2 in network if c==n1 and n2 not in s or c==n2 and n1 not in s } ``` More
First-freixodachamorra
This is an anti-pattern: ```python string = '' for i in self.connected: string += i.name + ' ' string = string[:-1] ``` You could write this instead: ```python string = " ".join(i.name for i in self.connected) ``` This is alternative for 85-89: ```python return {node.name for node in nodes More
quick and dirty :D-for14556 1
This 10. if c == end: 11. found_begin = False could be: 10. if c == end: 11. return tmp_string More
chain from iterable of ranges-PythonWithPI 1
It's shorter and more readable with a generator expression: ```python return chain.from_iterable(range(l, u+1) for l, u in items) ``` Regards, suic More
range-Joni_Braslaver
As you actually don't use `item` except for decomposing it, you can do the decomposition directly in the for loop: ```python for first, last in items: # ... ``` Regards, suic More
First-tanya 1
A bit shorter and more efficient: ```python for a,b in sorted(items): mas += range(a,b+1) ``` More
First-freixodachamorra 1
That list comprehension on line 6 is redundant: ```python # you can use `list()` instead of list comprehension output.extend(list(range(i[0], i[1]+1))) # but you don't need it as `list.extend` takes iterables so you can use range directly output.extend(range(i[0], i[1]+1)) # and there's a shortha More
Short, correct and absolutely rstripped-tovrey
Compared to other creative solutions, this one has at least a `lambda` :) More
First-x2wing
In Python `super().__init__()` is enough. Also, you could make `is_alive` a property which prevents accidental assignments. Regards, suic More
6502 like pseudo assembly-Tinus_Trotyl 1
So, ASM means Absolute Sado-Maso? Btw. what is the purpose of (can't you just omit it)? ```python pass # BCS BITCNT ``` Regards, suic More