44
Last seen 5 months ago
Member for 10 years, 3 months, 4 days
Difficulty Normal
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
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
> Connections can be repeated in the initial data, but inside it store once.
I missed this sentence and modified my solution ([here](http://www.checkio.org/mission/friends/publications/gyahun_dash/python-3/list/?ordering=most_voted)).
More
It's simple and clear rather than puzzle.
if matcher.match(data):
return True
else:
return False
You can modify the above to return the bool value directly:
return matcher.match(data)
More
Brute Force version [here](http://www.checkio.org/mission/loading-cargo/publications/gyahun_dash/python-3/second/).
More
**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
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
cand = set(data)
for c in cand:
You can write as follows(del **cand**):
for c in set(data):
More
pos = int(len(wrk)/2)
You can use **//** instead of **int()**:
pos = len(wrk) // 2
More