21
artem rudenko
Last seen 10 months ago
Member for 13 years, 3 months, 3 days
Difficulty Normal
Software Testing Engineer
Intersting but think that is not the clearest solution for this task
More
Very pythonic rotate. The only thing to add is that there is no need to use list and tuple calls in your code - it will work without them.
More
Awesome, i spent a lot of time trying to find a formula you have used.
More
The only thing to add from me is that is not required to call list on map, e.g you can replace:
m=list(map(list,_m))
with
m=map(list,_m)
Also the 'rest' part:
#mark rest
for y in range(len(m)):
for x in range(len(m[y])):
if m[y][x]=='.': m[y][x]='S'
retur
More
Nice, the small addition is that:
list(range(n)) + list(range(n))
can be replaced with:
range(n) + range(n)
or:
range(n)*2
More
Nice. The only notice here is that you can use collections.deque and rotate method specifically.
More
It's not a good practice to use 'next' as a variable name. You can replace two 'for i in range(-1, 2)' with 'itertools.product(range(-1,2), range(-1,2))'
More
+2 for the fastest deque, one thing is that you can move list from 'for displacement in [(1,0), (0,1), (-1,0), (0,-1)]:' to outside or to replace it with 'for displacement in ((1,0), (0,1), (-1,0), (0,-1)):'
More
Think it can be simplified to:
def checkio(data):
return 0 if not len(data)else data[0]+checkio(data[1:])
More
Very good, note that line 4:
any((True for x, y in groupby(l) if len(list(y)) >= 4))
Can be updated to:
any(True for x, y in groupby(l) if len(list(y)) >= 4)
Also you can save matrix size e.g. 'len(matrix)' into a variable and use it.
More