57
Awesome Team
Vedran Čačić
https://web.math.hr/~veky
Last seen 3 hours ago
Member for 11 years, 6 months, 12 days
Difficulty Advanced
We shall not cease from exploration, and the end of all our exploring will be to arrive where we started and know the place for the first time.
It seems really hard to write an O(n^2) algorithm for this mission, but you've managed that. ;-[
More
If you're wondering how people wrote that pattern before walrus, check out my other solution. ;-)
More
Name, don't index!
width, height = room
for x_center, y_center, radius in sensors:
More
You should use the Smart Split (without an argument). That way you don't need `if array else []`.
More
There really is no reason for observers being a list: a set is much more appropriate.
More
I think you have confused The best number ever with The answer to life, universe and everything. :-P
More
> The list of banned words are as follows:
sum
import
for
while
reduce
Yeah, right. :-P
More
If you want to see smarter way, look at [my solution](https://py.checkio.org/mission/morse-decoder/publications/veky/python-3/weird-defaults/?ordering=most_voted&filtering=all). ;)
More
Wouldn't
[x] * f for x, f in items
be nicer than that horrible indexing? :]
More
Of course, the len checking can be done in the same way, at the expense of blowing up the code by a factor of at least 2. But that's even more wrong than this. :-D
More
Don't iterate over indices when you can iterate over the list itself.
for element in array[0:len(array):2]:
sum += element
BTW do you really need elif? Can len(array) be less than zero? :-) And while we're at it, a is already 0 in the empty case, you don't need to set it again. :-]
More
if...else expression is intentionally written with a syntax that emphasizes the regular case over singular one. So:
max(*args) - min(*args) if args else 0
And whenever you compare len of something with 0, slap yourself with a bool. ;-]
More
Obvious. :-) Just without those spurious spaces, it would be perfect. :-]
More
No need for all those parentheses. Python grammar is sane (mostly). :-]
a[n]**n if nMore
"sum" is a builtin. That should give you a hint. ;-)
Also, don't iterate through indices if you can iterate through elements themselves. ;-]
And, don't compare len with 0.
More
... if array ...
And you don't need 0, it's default left edge: sum(array[::2]).
More