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.
n>=0 is precondition, you don't have to check it. Even if you had, you wouldn't need parentheses. :-)
More
delta is ok, but names d0 and d1 are semantically empty. Much better would be not to use them at all.
delta = date(*date1) - date(*date2)
More
Lines 6~9... wat? :-]
return [minr, minc]
Also, code duplication is horrible. Factor it out?
More
Condition in line 7 is really strange. What is it doing there??
Also, int(round(blah, 0)) is just round(blah).
And if you really use Py3, those / are truedivs. Don't write -2.0, write just -2. (Or better yet, cancel -1 and use 2.:)
More
Clear?? Hm... classifying commands according to len? And checking "if letters != []" instead of just "if letters"? No, sorry. Not clear. ;-P
More
That's one horrible code duplication. But more importantly, it doesn't work, does it?
verify_anagrams("a", "ab")
More
Lines 1 and 2: LOL. :-) Sometimes it is easier to just bite the bullet and write what you really mean.
parens = {"(":")", "[":"]", "{":"}"}
You could have simplified line 12 by putting one lion in Cairo first (see my solution and respective comments for explanation;).
More
If you really wanted to be _clear_, you'd probably use .count('1') as before. ;-] n &= n - 1 is a nice trick, but not really "clear" IMO.
More
"wrd" is semantically empty. There is _no_ reason for line 2. Just say
for x in words.split():
in line 4.
Also, "> 2"?? You mean "== 3"? :-)
More
Aaargh. :-) See key argument for .sort (or sorted).
Also, calling .sort in every loop pass is really braindead. :-P
More
"elif" exactly means "not conditions above". So for example line 4 can be just
elif number % 3 == 0
(or elif not number % 3).
Also, you can return it instead of naming it. For example, in line 3, 'return "Fizz Buzz"'.
More
len_data makes no sense. It's just one char shorter than len(data), at the expense of a new name.
Line 13: O_O
More
Regarding that search function: you really should get acquainted with "any" and "all" builtins. They'll make your life much easier. :-)
return any(four_consecutive(comb) for comb in gen for gen in generators)
Or if you want to be fancy,
any(map(four_consecutive, itertools.chain(*generator
More
You might break out of these loops as soon as you see it contains_whatever (or use any which will do it automatically for you).
Also, lines 3~5 can be one line: contains\_number = contain\_big = contain\_small = False.
Just out of curiosity: might you be of Slavic origin? I ask because of strange
More