44
gyahun_dash
13 34 48
14278/ 15612
Last seen 5 months ago
Member for 10 years, 3 months, 4 days
Difficulty Normal
Best reviews / Newest reviews
re-gyahun_dash
Line 5: bins = [re.sub('(?P\d+)(\.)?', binarize, a) for a in adds] Line 8: pat = ','.join(['(?P\d+)\d*'] + ['\\1\d*'] * (len(adds) - 1)) More
First-seb.hoarau
def all_routes_from_node(m, node): possibilities = [] for arc in m: if node in arc: possibilities.append(arc) return possibilities How about using **list comprehension** here? def all_routes_from_node(m, node): return [arc fo More
First-blackfaced
def distance(x,y): return math.sqrt((x*x+y*y)) You can use **hypot** instead of sqrt of sum of squares: distance = math.hypot More
UserDict-gyahun_dash 1
I've tried to let **ConsistentDict** inherit **dict**, but it doesn't work: class ConsistentDict(dict): def __setitem__(self, key, item): if not key in self.keys(): dict.__setitem__(self, key, item) elif self[key] != item: raise ValueError #prohibit updates More
First-yuutan0301
You can write simpler by using **math.ceil** (if you don't hate importing **math**). **FROM**: x = 0 while x < radius: y = 0 while y < radius: #(skip) y+=1 x+=1 **TO**: for x in range(ceil(radius)): for y in range More
First-subaru
You can return **list(zip)** without **append**. More
Recursive solution-big312
if "1" in chemin and "2" in chemin and ... You can check **chemin** using **set**: if len(set(chemin)) == 8 and chemin[-1] == "1": ---- teleports_map = [(int(x), int(y)) for x, y in teleports_string.split(",")] You don't need to convert strings to **int**: teleports_map = telepo More
First-Hide99 1
You can return bool in **if statement** directly. More
First-samitchell 1
tens=(floor(number/10))%10 is equivalent to: tens = (number // 10) % 10 More
Second-gyahun_dash
To improve my code, I've used [Eldin's](http://www.checkio.org/mission/house-password/publications/Eldin/python-3/using-regex/#comment-outer-10787) as a reference. Thanks. More
First-gyahun_dash
I'll modify post-processing. FROM: if match and all(a != b for a, b in combinations(match.groups(), 2)): return structure_grid_from(candidate_words) TO(delete **structure\_grid\_from**): if match and all(a != b for a, b in combinations(match.groups(), 2)): _dict More
First-Hide99
pos = int(len(wrk)/2) You can use **//** instead of **int()**: pos = len(wrk) // 2 More
stack-blabaster 1
adjacent = [set() for _ in range(i)] How about **collections.defaultdict**? adjacent = defaultdict(set) More
First-Hide99 1
cand = set(data) for c in cand: You can write as follows(del **cand**): for c in set(data): More
Tiles distance probe-Ch0bits
distance = lambda x, y: math.sqrt(x**2 + y**2) You can use **hypot**: distance = math.hypot More
Verify anagrams-OZMA
for i in word2: if i in word1: if word1.count(i) == word2.count(i): word1 = word1.replace(i, "") You don't need first **if** because second is False if i is not in word1(left=0, right>0). More
First-gyahun_dash
[revised](http://www.checkio.org/mission/the-square-chest/publications/gyahun_dash/python-3/5th/) More
First-gyahun_dash
Appendix: font = 27499, 11410, 29415, 29327, 23497, 31118, 14827, 29348, 31727, 15310 More
First-Hide99 1
**string.ascii_uppercase** is helpful for your code. pair = [(chr(x), l.count(chr(x))) for x in range(ord('a'), ord('z')+1)] a = max(pair, key = lambda x:x[1]) You can use **l.count** in **lambda function** as follows. By doing so, you don't need to create the list of pairs. a More
First-AoMao
def threeof(string): return (string[0] != ".") & (string[0] == string[1]) & (string[0] == string[2]) You can integrate the expressions. def threeof(string): return (string[0] == string[1] == string[2] != ".") More
1
2
3 4 5