57
Awesome Team
Vedran Čačić
https://web.math.hr/~veky
Last seen 45 minutes ago
Member for 11 years, 6 months, 7 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.
You could have:
* used p in defining q, that way it would be much more clear those are binomial coefs
* extracted square root of h in place, instead of twice later
* written the return value as max(p(w), n - q(w))
Otherwise, nice solution. And yes, I appreciate documentation, so I can po
More
Could be simpler, cleaner, _and_ use less memory if you removed the brackets.
''.join(letter for letter in text if letter.isupper())
BTW .istitle is not exactly the same. It is used when the desired output has only first letter of word emphasized by case. Although the test example gives exactl
More
It's nice and all, but haven't you overengineered it a bit? :-) The board has 64 squares, not a million. :-)
More
A very nice idea. :-) However, the implementation of is_perfect_square could be more robust by using round instead of int.
More
At first sight, this is usual high-order functional stuff. But there are a few puzzling details, in the form of code that should do nothing, but without it, the solution doesn't work. :-]
* Why is that "if (push, pop, peek)" there? 3-tuple should always be true, right?
* Why is that "and (yiel
More
Why not simply "return l == list"? Lists are equal, not only their lengths.
More
Argh - there _is_ a number between 1 and 3 after all! :-D
And that is the number of thumbs you get. :-)
More
You're aware that you wrote the same thing three times? :-)
More
Specialcasing what shouldn't be specialcased, sorting to find the minimum, list "comprehensions" which do nothing at all... :-/ A perfect example of how you can't fix the bad code by documenting it. :-]
* What's wrong with treating 0 the same as all the other numbers?
* Imagine you have a thousan
More
Inspired by an (algorithmically beautiful, Pythonically ugly:) [RRRQ's solution](http://www.checkio.org/mission/striped-words/publications/RRRQ/python-3/first/).
More
chain(*map(f, l))
is what you're probably looking for. ;-)
(And it has nothing to do with ChainMap.:)
More
Nice handling of empty stack. :-) But the end is just
return not stack
More
Nice BFSolution. :-) Here are a few suggestions:
list.pop(0) performance is much weaker than it needs to be (linear
complexity). For a queue, it's much better to use a collections.deque, and
.popleft from it. If you don't want to import collections, and your queue
isn't using a huge amout of poplef
More
You can drop the []. "".join(l for ...) is clearer, more direct, uses less memory, and potentially faster.
More