23
Last seen 2 years ago
Member for 8 years, 8 months, 13 days
Difficulty Normal
`is_alive` should be a "property".
To keep it simple, a property is a function which can be invoked like an attribute.
Here's the syntax:
@property
def is_alive(self):
# return something
More
Very clean solution.
Just a little question. Wouldn't `max` be simpler than `sorted(...)[-1]`?
More
Clever solution.
To get the metals, a simpler solution would be
metal1, metal2 = k.split('-')
You could also declare `METALS` as a set at the beginning for efficiency.
More
Hi,
Here's a little Python trick. You can replace your last if by
return min_quantities[-1] or None
If `min_quantities[-1]` is not 0 (i.e. is `True`), it will be returned. If it is 0 (i.e. is `False`), `None` will be returned.
More
I was surprised to see so many negative comments for your solution.
It is a similar to mine but a bit more compact and I dare say "elegant". Whether it respects the format you're supposed to use for answering or not isn't really relevant. The purpose of being able to look at other people's code is t
More
Nice short solution but you could greatly improve its readability with meaningful variable names.
More
Instead of `n > len(array) - 1`, I find `n >= len(array)` more natural. But that's just a detail.
More
Sure.
With your algorithm, you check every value between the min and the max. If max - min = 1,000,000,000, you're going to check 1,000,000,000 numbers even if the array has only two elements.
If you sort the array first, you only need to check pairs of consecutive numbers in the array. If their d
More
Hi,
I'm sorry but this is not fast at all. "t in reversed_text" is O(n^2). That makes your algorithm O(n^4).
More
Hi,
There are solutions without loops. Hint: How many days are there in a year? (modulo 7)
More
Nicely formated and documented.
More
Hi,
For simplicity, you could move the `ret.append(letter)` before (or after) the if.
More
Hi,
Since you find the digits from highest to lowest, you can just reverse the list instead of sorting it. It's a tiny bit faster.
More
Hi,
It's certainly short but unreadable. You should have kept the original variable names.
More