57
Awesome Team
Vedran Čačić
https://web.math.hr/~veky
Last seen 1 day 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 don't need "+" in your regexen (you even don't have it in the first one:). And you don't need r here, though maybe it is good to always write it to remind you of regex parsing. But the last one then really ought to be \d. ;-)
Also, you don't need bool around the first condition, and even on the
More
Nice reorganization into tens and dups, but the code has some horrible duplication. You can do much better. ;-]
Here is an interesting approach, that tries to stay faithful to your algorithm. Of course, if you're willing to depart a little from your original algo, you'll be able to write much bette
More
Yup, that's good. ;-)
I hope you're aware that you could have written "rue" after T instead of that [0], and still have the same number of characters? :-)
More
Nice. Trivia: set("GS") is probably nicer than {'G', 'S'}. And a bit more substantial thing: enumerate has optional second parameter. Here enumerate(...,1) would probably help. ;-)
More
Too many parentheses. :-D Also, line 6 is simply "if array:".
And one more hint: when you see something purple, Python is trying to tell you something. Precisely, line 5: sum is already there, and it does exactly what you want. You might want to learn about slicing too.
More
Wooow! FT in singledigit number of lines. Totally cool. :-)
However, I can't give you more thumbs, since you artificially limit the degree of polynomial. Have you thought about using 1 << expr.count("x").bit_length()? I think it wouldn't slow you down much, and you'd have a general algorithm.
More
Really too complicated, and not working with Pythonic data structures. get_positions is really criminal in that regard.
More
Those ifs could really be simpler. elif is useful. ;-)
And redundant assignments really made me scratch my head. Why not just increment partial in one branch, and full in another?
More
Not very funny, and really not unusual. (I know it's subjective.)
More
A curiosity... `min(4 - i % 4, 4 - i // 4) + 1` is just `5 - max(divmod(i, 4))`. :-)
More