57
Awesome Team
Vedran Čačić
https://web.math.hr/~veky
Last seen 23 hours 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.
What do you think lines 9, 18 and 19 are for? I think you misunderstood what "precondition" means.
More
`from datetime import date` might be more appropriate, since you only need that one, and you need it twice.
More important: learn about `*` argument splicing.
d1, d2 = date(*date1), date(*date2)
And a curiosity: `timedelta` knows how to `__abs__`. So you can drop the outer parens.
return
More
You really like that "str", hm? :-D
Also, you don't need "base=".
And _please_, don't write empty except. It catches much more than you think.
More
Now when people ask me how dimpleqonx works, I'll just point them to your code. Thanks. :-D
More
LOL, this really wins an award for the most complicated solution of the task. Famous `if`/`pass`/`else` construct, returning `True` and `False` in separate branches, useless `print`, hardcoded "abc...", populating `Counter` in the most roundabout way, semantically empty name used only once, and
More
`", ".join` could really help you in line 21. ;-) And corners might benefit from calculating east and north separately.
More
What's this epidemic separation of return with two empty lines from the rest of the function?? Where do you get this idea, people? :-/
More
LOL @ `reverse=False` part. :-) You know False is default here, right?
More
You like functional programming, don't you? :-) Well, sometimes it's cumbersome for no reason. For example, line 11 could be:
res = [['.XO'.index(l) for l in s] for s in res]
and then you wouldn't have to repeat convert(res) twice.
BTW look at builtin functions all and any, they might be able
More
Wasn't it easier to do that `set(connection.split("-"))` thing only once? :-)
Also, `break else return` is a powerful pattern that's better than bool flags.
See [my solution](https://py.checkio.org/mission/find-friends/publications/veky/python-3/tinus-trotyls-pythonified/) for implementation. :-)
More
First, lines 6~9: for loop would be nice.
Don't iterate through indices when you can iterate through sequences themselves. Line 23: "for char in word[1:]:".
Lines 25 and 30: wouldn't it be better to reverse elses, and remove nots?
Lines 34 and 35 are just count += passed. But in fact, those contr
More
a and b or c is deprecated. :-) Since you obviously don't intend to golf every character out of it, you can use "b if a else c".
More
Your spaces are a bit inconsistent. At least put space after `*=` if you put it before.
Also, if you `int(n)` before, it would be easier to write a condition:
d = int(n)
if d:
result *= d
More
`self` is a weird name in this context. :-)
That duplication of code for rows and cols... wouldn't it be much nicer to write a function?
for i_row in around(row, len(grid)):
for i_col in around(col, len(grid[i_row])):
yield grid[i_row][i_col]
In fact, by using slice instea
More
`ele` is a weird abbrevi. :-) They usually don't end with a vowel.
Making a new list (via comprehension) would probably be easier than modifying the argument. And if you really wanted to iterate through a copy, saying `.copy()` is probably clearer than `[:]`.
More
It's funny how your naming quickly deteriorated from
most_wanted_letter_alpha # wow, I'm feeling so powerful
to
a # ah, to hell with it already!
:-D
More
`if len(args) > 0` is unpythonic. Just use `if args`.
Or, if you really want to use len(args), use it interestingly:
len(args) and max(args) - min(args)
;-)
More
As I said already, drop [] inside (). You don't want to make a list just to ",".join it. You just want to ",".join values in order.
More