21
artem rudenko
Last seen 9 months ago
Member for 13 years, 2 months, 19 days
Difficulty Normal
Software Testing Engineer
The only thing to add here is that it's recomended to use isinstance instead of type.
More
Cool, small tips:
for x in range(0,8):
No need to specify 0 in range, e.g. can be replaced with:
for x in range(8):
Two 'for' statements can be replaced with itertools.product:
for x in range(0,8):
for y in range(0,8):
is the same as:
for x, y in product(range(8), range(8))
More
ifs))) each and every time i am seeing a lot of ifs i wonder about switch...case. Unfortunatelly in python we have only dicts to somehow cover switch..case functionality. In any case thumbs up)))))
More
To get rid of i[0] and i[1] you can write:
for rshift, cshift in moor:
Aslo there is no any need to use redundant parentheses in the code below:
if(0<=row+i[0]More
Not a good idea to redefine 'sum' as a variable since it is a python core function. Also there is not need to do split: int(cmd.split(' ')[1]) - you can use int(cmd[-1]) instead.
More
Awesome))) I have used almost the same idea, however i have created too many redundant checks
More
From the stackoverflow and some python speed tips and trics is not a good way to shift list right using pop and insert. Specifically insert is a very slow list operation. Instead of your rot(l) function you can take a look at collections.deque.rotate.
More
Small addition is that you can replace 'sorted(enum(rods), key = lambda ir: ir[1])' with 'sorted(enum(rods), key = itemgetter(1))'
More
Nice, seems we think the same way)) at least while creating solution for this task
More
Thank you all for your comments. This solution has been written a long time ago and as you all probably know no one able to edit it. What i am asking you is to give full review with comments instead of commenting ugly and etc. I know this - trust me.
Thank you
More
Nice, but think that this is not a good practice to use 'import *' especially in case when you need only 'Fractions'. Also is not really needed to wrap return result to list.
More
You can use getattr(hashlib, algorithm) instead of if here. In any case - cool.
More
Quite an interesting solution. I never thought that it can be done this way(from my point of view - quite unpythonic).
More
Cool, but what if to calculate len(args) once and use calculated value then?
More
Cool, note that you can use Fraction(1) instead of Fraction(1, 1)(https://docs.python.org/2/library/fractions.html#module-fractions)
More
Great, that what i was thinking about, but not succeded. The best sample of reduce and operator using.
More