57
Awesome Team
Vedran Čačić
https://web.math.hr/~veky
Last seen 20 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.
A man. A plan. Weird error. Banana!
On a more serious note, that STAT really calls for `numpy.ndarray` (2x2x2) approach. :-) Indexing is much nicer, instead of that abomination in line 8. :-)
And `except: return None` is cleaner written as `with contextlib.suppress(Exception):` (because I really d
More
Yes, that's how a 7bit washing machine embedded microprocessor would solve the problem. :-D Python has a bit richer data structures on your disposal. :-]
(Unfortunately, the code for 8 is not valid ASCII... but neither is its complement. Ah, the good old times of punched cards...:)
More
First, line 5 is
if not array:
Second, sum is a builtin. You don't have to maintain it manually.
Third, indexing from range is just a slice. array[::2].
More
Lines 20~23 are really just one line. Hint: min.
Please don't print(str(corn) + " corn is left"). Do
print(corn, "corn is left")
print is smart enough to strify automatically, and even to put a space between. ;-)
Lines 2~3:
pigeons = minute = 1
More
numstring is semantically empty, str(number) says the same thing in a clearer way.
You could even iterate
for digit in map(int, str(number)):
You don't need != 0 in line 7:
if digit:
answer *= digit
More
Line 18 is wrong. rounded gamma is _not_ necessarily equal to 180 - rounded alpha - rounded beta.
BTW why do you reinvent the wheel (in this case, builtin round function)?
More
`set` has a much more versatile API than just "make null, add, and count elements". :-) Also, it's very nice to use `string` for `punctuation`, but whitelisting is more useful than blacklisting. See my solution.
More
Instead of args, you could have cached \_\_repr\_\_ itself. ;-P
But really, why all this caching? You're just making it harder to mutate Buildings afterwards.
More
Yes, it's fast. But I wouldn't call it "simple". You have duplicated code fragments at two places in the code, leading you to name lambdas - which is not as bad as PEP8 makes it seem, but still can be avoided.
First one is easy:
if day != current_day:
current_day = day
total +=
More
That max with 0 seems really ugly in a Clear solution... having another if would be too much for you? :-)
More
The same as [Aperiodic](https://py.checkio.org/mission/periodic-table/publications/veky/python-3/aperiodic/), only readable. :-D If you ever wanted to see how that one worked, but didn't have courage to tackle it. :-]
More
Yup, that's factored. But since you already use the slice in line 7, it would help you in line 6 too.
... or parts[-1:] != ['..']
More
What's the point of having a good solution in the docstring, and then an inferior one in the code?
More
`max` has a `default` keyword, too, which you can use to avoid lines 5 and 6.
Also, re's forward looking might help you so you don't have to extract `group(0)` as a separate operation.
More