19
Last seen 6 years ago
Member for 10 years, 1 month, 5 days
Difficulty Normal
from Kazan, Russia
Learned Python from checkio
elif 'POP' in cmd.upper() and len(stack)
can be rewritten shorter:
elif 'POP' in cmd and stack
More
1. string module is imported but never used in code
2. 'for y in range(0, 5)' can be written shorter 'for y in range(5)'
3. first two cycles are using magic numbers 5, 6 anyway. They could imply fixed word positions without much loss. And something should be done about code repetition. Pacck two a
More
Code could use some simplification:
cache=[]
for item in network:
cache.append(item.split('-'))
or even
cache = [item.split('-') for item in network]
More
Why to call __next__(), when you can just use next()? Is it faster or what?
More
if array != [] -----> if array
sum(array[i] for i in range(len(array)) if i % 2 == 0) ----> sum(a for i, a in enumerate(array) if not i % 2)
More
Setdefault() returns the key value available in the dictionary and if given key is not available then it will return provided default value. So setdefault(x, x) should be always equal to x, right?
More
n = []
for i in network:
n.append(i.split('-'))
can be made clearer and shorter:
n = [item.split('-') for item in network]
More
Did you really write this code? It's confusingly outclasses other solutions.
More
It is clear, all right. Commenting, variables naming, extra functions for easy reading. Nice.
More
There is set comprehension in Python:
def col(grid, x):
return {r[x] for r in grid}
More