45
Awesome Team
Masayuki Hayashi
Last seen 40 minutes ago
Member for 8 years, 1 month, 24 days
Difficulty Normal
It's elegant solution :)
I think that using 'str.maketrans()' is more readable.
Line 13:
for word in code.translate(str.maketrans('.-', '01')).split(' ')).capitalize()
More
It is an interesting idea.
But, How about the following case?
assert g_key([[9, 9, 9, 9, 9],
[9, 9, 9, 9, 9],
[9, 9, 0, 0, 0],
[9, 9, 0, 9, 9],
[9, 9, 0, 9, 9]], 14) == 117
More
good solution!
and I try more simple ( line : 2-12 )
words = [(ord(w[0])-96)*10 + int(w[1]) for w in list(pawns)]
More
directions = [v for v in permutations([-2, -1, 1, 2], 2) if (abs(v[0]) + abs(v[1]) == 3)]
Good :-D
The Manhattan-distance of knight's movement is always 3 with 5x5 grid.
More
awesome solution.
I used this solution to improve Visibility's `init.js`.
More
Nice memoization.
Line 30 equivalent the following:
if not monster_ctr - lett_ctr:
More
I thought of another expression of Line 20-23:
for center in {a+b for a in A[radius: -radius] for b in B[radius: -radius]} - obstacles:
check = center
More
Thank you very much for checking my code!
I feel the code is redundant.
But this is the most I can do now.
>PEP8 violations (long lines)
Thanks, I will check PEP8.
More
It is an interesting idea.
But, How about the following case?
assert g_key([[9, 9, 9, 9, 9],
[9, 9, 9, 9, 9],
[9, 9, 0, 0, 0],
[9, 9, 0, 9, 9],
[9, 9, 0, 9, 9]], 14) == 117
More
good.
Your result can be reduced.
fix last code:
return [int(n) for n in set(result) if result.count(n) % 2]
More
nice solution.
Python has a `defaultdict()` that has similar functionality to `append_to()`.
from collections import defaultdict
conn_hash = defaultdict(list)
for a, b in lst:
conn_hash[a].append(b)
conn_hash[b].append(a)
More
Nice solution.
another way of Line 16-17 :
a = sum(lit[0] <= set(d) <= (lit[0] | broken[0]) for d in DIGITS)
b = sum(lit[1] <= set(d) <= (lit[1] | broken[1]) for d in DIGITS)
More
This mission accepts iterable in its output.
Line 39:
return map(len, result)
More
Amazing speed!
However, because of the greedy code, the random test fails with low probability.
More
Thank you!
I did't know such a method.
and find “Format specifications”.
pt = format(pattern, '0'+str(len(command))+'b')
More