31
Andrey Solomatin
Last seen 1 year ago
Member for 11 years, 2 months, 9 days
Difficulty Normal
no: **p = list(map(lambda x:None, METALS))** yes: **p = [None] * len(METALS)**
no: **if p[idx] == None:** yes: **if p[idx] is None:**
no: **[frac,]** yes: **[frac]**
you can replace: **sary = list(map(sum, zip(sary,div)))** with more readable list comprehansion **sary = [sum(x) for x in zip
More
Put statment after **if** on new line, add spaces around binary operators.
More
Line 18 looks strange. Why you choose 10000? Why not 42? And better to put it inside solve function.
In you case you should use q.pop() instead of q.pop(0). You can find explanation [here](http://stackoverflow.com/questions/195625/what-is-the-time-complexity-of-popping-elements-from-list-in-pyt
More
PEP8: For sequences, (strings, lists, tuples), use the fact that empty sequences are false.
Yes:
if not seq:
if seq:
You should use slice notation.
More
Very complex:
zip([game_result[i][0] for i in range(3)], [game_result[i][1] for i in range(3)], [game_result[i][2] for i in range(3)])
same as:
[tuple(x) for x in game_result]
zip([game_result[0][0]], [game_result[1][1]], [game_result[2][2]])
same as:
[(game_result[0][0], game_result[1
More
Not need to check both isdigit and isalpha, they are opposite.
You can specify more exact condition. **c >= 3** It is not possible to have c more then 3.
Who need s break if you can return.
no: **return True if c >=3 else False** yes: **return c == 3**
More
This looks bad: **line = [0 for i in range(0,num)]** you can use: **line = [0] * num**
You can use **copy.copy(line)** or **list(line)** or **line[:]** in line 39. No need to deepcopy.
More
You can put all 3 cycles to product:
for i, j (dj, di) in itertools.product(xrange(N), xrange(N), DIRS):
It is bad practice then program raise exeptions during normal flow.
You can replace **raise** with **continue**
More
no: **word == other\_word[-len(word):]** yes: **other\_word.endswith(word)**
More
There is function in standard library that do the same as **lambda x: abs(x)** you should use it instead of this lambda.
More
if you repeat something a lot of times, then you doing it wrong. You need to use some kind of iteration.
More
For **units** and **half** you can use strings not list.
Please follow common code style for python. [PEP8](http://www.python.org/dev/peps/pep-0008/#other-recommendations)
More