16
Alex Ramanau
Last seen 9 months ago
Member for 12 years, 1 month, 9 days
Difficulty Normal
I think that your solution is a little bit complex and difficult to read.
Here is some areas, which may be improved:
1) Using lambdas here doens't make any profit, because they don't use any variables from outer scope - just convert them to plain functions(or you can just embed dist/hyp funciton i
More
Looks good, return median could be performed after if..else. (-1 line of code;) )
More
Correct solution, but it could have poor performance on big input.
Could we do better?
Think about using other data structures, e.g. dict.
More
A lot of magic here, what is the meaning of all this number inside function body?
More
Hi, your solution is pretty straightforward and undestandable! And it has type hints, awesome!
However, it may be improved a little bit:
1) Try to move logic with calculation distance and angles to separate function(they may be nested to similar_triangles), it will decrease code duplication and wil
More
Not bad and clear code, but we can make it more efficient. If you want, you can do the same task in **one cycle for**.
Remark: each data.issomething() have one cycle inside.
More
В целом всё ОК. Именование переменных можно улучшить:
например x назвать product (произведение), i - digit.
More
try
...
except
pass
-> is not OK for this task. And also it's a bad style at all. What if you perform some syntax error inside this block?
More
Generally it's better to gather words into list:
letters = []
for each_letter in text:
if each_letter.isupper():
letters.append(each_letter)
Why? Because appending to list is cheaper than concatenating strings. string in Python are immutable and always copied.
More
>>> min([])
Traceback (most recent call last):
File "", line 1, in
File "", line 9, in min
IndexError: list index out of range
Is this desirable behavior?
More
No **kwargs is needed for min/max according to mission description. You need just the one keyword argument `key`. Min and max can be found more efficient without sorting and copying input data.
More
Using type annotations - good practice.
However, it would be better to split solution to multiple functions for better readability. Maybe just move spacer function out of text_formatting.
More