15
Last seen 1 year ago
Member for 8 years, 9 months, 16 days
Difficulty Normal
It take me a moment to understand that
result += n // arabic * roman
means: put in `result` string (`n // arabic`) times the `roman` string
More
⛳👍 Liked [topological_sort](https://docs.sympy.org/latest/modules/utilities/iterables.html#sympy.utilities.iterables.topological_sort)
More
Improve it using collections.deque, then you could substitute pop(0) by popleft()
pop(0) is [quadratic](http://www.checkio.org/mission/letter-queue/publications/veky/python-3/double-ended/share/d1d2a0a6c9a81443d0be2e611f017b4d/#comment-17077)
More
Good use of [conditional expressions](https://docs.python.org/3/reference/expressions.html#conditional-expressions).
More
Yo could try to use `collections.defaultdict(set)` to simplify
letters = {}
for word in word_list:
for i, letter in enumerate(word):
if letter in letters.keys():
letters[letter] |= set(word[i+1:])
else:
More
Liked the memoizing decorator [functools.lru_cache](https://docs.python.org/3/library/functools.html)
More
`array[::2]` is the shortcut notation for `[array[i] for i in range(0, len(array), 2)]`
More
You could use `elements[-2]` instead of `elements[len(elements)-2]`
More
You could substitute asking for `w` and `b` to be zero by `w < 0 and b < 0' and return zero
More
If you want a little improvement, seems that `reversed(list)` is more 'pythonic' than `list[::-1]`
More
Have you thought in using a while checking for changes in `ch` instead of using recursion?
More
What is the logic behind `n = len(marbles) ** step` to be the recursion levels ?
Shouldn't be `step` the deepness of the recursion and 2 (or `len(marbles)`) the wideness?
More
You could simplify your code:
* Using divmod function
* Storing words in a list instead of a string and joining it with
' '.join(list_of_words)
More
Not maintainable. It's unclear what is doing without debugging it.
Could improve it by converting vertices2 into a static grid of relative positions ((-1,1), (-1,0), (-1,-1), (0, 1), (0, -1) ...
and checking out of boundaries into the for loop.
More
prints are good for debugging, but is better using logging than print, because you can turn it off to WARNING when you got into production environment. Example:
logging.basicConfig(level=logging.DEBUG) # WARNING or DEBUG
...
logging.debug(the_string_you_want_to_print_when_debugging)
More
Have you thought in using `split` or slicing instead of `re` to improve legibility.
More