57
Awesome Team
Vedran Čačić
https://web.math.hr/~veky
Last seen 18 hours ago
Member for 11 years, 6 months, 6 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.
I'm not quite sure what are you trying to accomplish. You practically torture Python with your horrible pile of symbols, as if you try to golf, but on the other hand, you miss so many obvious optimizations in that regard. (No, I'm not talking about my `-s%10`.:) For example,
(lambda d: abominat
More
Nice (though could be simpler, of course), but the asymmetry between handling hour and minute (oops, time[1]:) is kinda odd. I think better would be
hour, minute = map(int, time.split(':', 1))
More
Interestingly different from mine. ;-)
More
Nice regex formation. :-D But seriously, some other things might be
improved a lot. String methods, especially .isupper and .endswith, should
be considered.
More
Yes, O(n) is nice. And of course, if the answer is True, then it's the best you can do. The question is, can you do better if the answer is False? :-]
More
Yeah, that's ok - if the argument is really a list (or any sequence). But imagine someone asks
d = {2: 8, 6: 5, 4: 8}
all_the_same(d.values())
where you can iterate through the argument, but there is no `...[0]` operation. Can you still have the same complexity? :-)
More
You're still converting to binary, only you're doing it yourself instead of having Python do it. :-)
More
If you're wondering how people wrote that pattern before walrus, check out my other solution. ;-)
More
That loop hardly qualifies as math... you could have used recursion then. 🤓
More
It can be even clearer [without them](https://py.checkio.org/mission/boolean-algebra/publications/veky/python-3/an-operator-by-any-other-name/). :-]
More
This is a beautiful algorithm. Too bad it's written in Java, not Python. :-P :-D
More
Instead of +1, you could have used the second argument of sum.
And instead of that ord business, you could have just sum the bytes. ;-) [See the "Happy New Year" thread on the Forum for details.]
More
> The list of banned words are as follows:
sum
import
for
while
reduce
Yeah, right. :-P
More
Ah, yes, the "sugrically removed recursion" solution. :-D But still, it's nice that you converted it to BFS (queue) instead of the obvious DFS (stack) one.
(Not more than 3+ because you're too anxious about types. In a duck-typed language, it is mostly just nuisance.)
More
> The shorter your code, the more remarkable you are.
Then I am https://remarkable.com/ :-D
More
`yield from` with a genexp is almost as bad as map with a lambda. It has its uses, but these do not include this one. Just use a loop.
for g in gen_die(length - 1, remain - i, i): yield g + [i]
And stop case for recursion can probably be pushed one less level, to
if not length: yield []
More
What do you think line 9 is doing? (True answer is: nothing.)
Lines 10~18: From Zen, *Flat is better than nested.* You still have condition duplication, it's just that code is harder to read.
More