57
Awesome Team
Vedran Čačić
https://web.math.hr/~veky
Last seen 11 hours ago
Member for 11 years, 6 months, 24 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.
for it:
if not cond:
continue
doit
is a strange antipattern. Wouldn't
for it:
if cond:
doit
be clearer?
More
Nicely explicit. :-)
[Nitpick: I don't know why you're importing date. I mean, I know why, but you're wrong.:]
More
Aumph. Too many weird things here.
First, use round builtin. Don't fool around with math.floor, + 0.5 and other hairy stuff.
Second, when you round alpha and beta, and subtract them from 180, you won't necessarily get rounded gamma. I'm sure you know it.
Third, that "test" function really h
More
Different operators can be chained too.
if a == b == c != '.': return a
More
Instead of .keys, try using .items:
for i, f in lettersFound.items():
Then you can write f instead of lettersFound[i] every time.
More
?? What _did_ you think float(median) does? Changes the type of a live value? :-O That's impossible even in C. ;-P
More
I'm not quite sure what you _get_ by eliminating fractions (since you still do the same operations, just above the big common denominator), but for bragging rights, it's ok. :-)
More
Using list.append when you want a bound method is _really_ confusing. I advise you reconsider your name choices. ;-]
Don't iterate through indices if you need elements.
for x in data:
if data.count(x) != 1:
result.append(x)
And what do you think line 15 does?? Hint
More
If you know about collections, you should know about collections.Counter. ;-)
BTW, line 6 would probably be more readable as
if 'a' <= c <= 'z':
And learn to use min with key parameter. Much tidier than Schwartzian transform. ;-)
More
(copy is not really needed, could be avoided with more careful coding.)
routes[a, b] is easier written (and read) as routes[a, b].
Lines 17 and 19 could be combined with "or" (or even negated, avoiding "continue", but that's subjective).
DIRECTIONS probably shouldn't be a dict, but a set of
More
Very uniform. :-) I don't really get why you extract MARK_O and MARK_X to the beginning, but a maybe interesting fact: if they were frozensets, you could have a set of them in line 10 (and "set in set of frozensets" construct works fine).
More
collections.Counter is screaming "Use me, use me!!". :-P
Again, line 4 is completely unnecessary.
And line 2 too. You can just `for x in text.lower()` inline.
key is much more versatile than this. It doesn't need to be something directly inside the items you want to order. See my solution for exa
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