40
Last seen 4 days ago
Member for 9 years, 10 months, 19 days
Difficulty Advanced
A few comments:
1. In fact lines 5-7 are superfluous as a, b and c don't have to be sorted.
2. Then:
a, b, c = length
is the same as
a = length[0]
b = length[1]
c = length[2]
3. Consider creating a separate function from:
round(degrees(acos((b * b + c * c - a * a)
More
Good job! There's no redundancy. And it's even safer than it has to be, as all inputs in the tests are already sorted :)
More
You don't have to use third variable two swap values of two variables. You can simply write:
if n < m:
m, n = n, m
instead of:
if n < m:
tmp = n
n = m
m = tmp
More
You can use the [str.rjust](https://docs.python.org/3/library/stdtypes.html?highlight=str.rjust#str.rjust) method for this:
fill = abs(len(n) - len(m))*'0'
if len(n) < len(m):
n = fill + n
else:
m = fill + m
More
_nbin_ and _mbin_ are both _str_ which is iterable there for using list() in lines 10 and 11 is superfluous. And also you can write:
size = max(len(nbin), len(mbin))
More
Few tips:
array[len(array) - 1] == array[-1] # there's no need to write len(array)
n = n + 1 --> n += 1
0 % 2 == 0 # you can omit n == 0 in your if clause
The code in else branch doesn't have to be in else branch.
More
The return None in your code is never reached, you may remove it.
More
Hi,
1. Line 10 is redundant.
2. You use `len(data)/2` three times, so it's good candidate for a variable.
3. Line 3 is more readable this way, but you could also write it like this:
if len(data) % 2:
...
More
Hi, this:
for i in range(len(data)):
if data.count(data[i]) > 1:
data_1.append(data[i])
i = i + 1
else:
i = i + 1
# could be replaced with:
for i in data:
if data.count(i) > 1:
data_l.append(i)
But you can use _f
More
I'm nitpicking (so don't take it too serious): Romanian numerals? :) rumuński != rzymski.
More
Hi, I like lambdas but in this case I agree with @PaulBrown. One tip to make code a bit more readable:
Separate long comment from code, e. g.:
# returns sum of 2 rows starting from column fromcol,
# where second one is multiplied by mult
addrows = lambda row1, row2, mult=1, fromco
More
Hi, I would shorted valid like this:
return all(0 <= spot[i] < len(dfs.matrix[i]) for i in (0, 1))
More
Hi,
1. You could use `int.__mul__` instead of `lambda`.
2. `new_number` is redundant. You can put that comprehension in `reduce` directly.
More
Hi,
1. `== True` is redundant.
2. `...if...else...` on line 5 is redundant:
new_sentence = [x.isalpha() for x in sentence.split()]
# or you could use map
new_sentence = map(str.isalpha, sentence.split())
More