22
Dahlia Ramm
Last seen 1 year ago
Member for 8 years, 1 month, 3 days
Difficulty Normal
Maybe a bit too much for this task **but** a great example on what is possible.
This also is the best approach if you ever want to decode a roman numeral to decimal rep.
Just add decode method and your're done.
Great!
More
Whoo, took me some minutes to figure out how the lamdba works here (thanks to Pythontutor :D)
Really cool!
More
Very complicated and lots of redundant expressions.
- Line 12:
a = n
What for? You are not reusing the original value of _n_ anywhere, so why do need a copy of it?
- Line 16:
a, c = a//2, a%2
using _divmod()_ is shorter and clearer...
a, c = divmod(a, 2)
- Line 17 to 18:
More
Wow, this one is scary!
+ the readability of this is bad
while True:
if flist[len(flist)-1] > 5000: break
else: flist.append(flist[len(flist)-1]+flist[len(flist)-2])
what about this?
while flist[-1] < 5000:
flist.append(flist[-1] + flist[-2])
+ You are
More
Hm...
Correct idea but you haven't thought it to the end.
Your `add_food` and `add_drink` methods are **exactly** the same in all the concrete classes, so why do have to enforce yourself to override them in each subclass?
And your `total` method doesn't need an override too. You could simply use
More
@veky once argued with me, because I was mapping a lambda. He explained that this is a LISPsm!!!
I don't see why using a LISPsm is bad, by **I do agree** that mapping a lambda is not good when an generator expression can do the job:
max(
(len(list(v)) for k, v in groupby(line), default=
More
Cheater!
The taks asked you to **calculate** the return value and not to look it up in a table. :D
More
line 4:
for let in list(text)
why are you casting 'text' to a list? Strings are iterable!
line 5:
a.append(let) if let.isupper() else []
what is the else for?
What exactly is line 6 for?
You are assigning a copy of a to b while
return ''.join(a)
would have done the same.
More
and one more time...
Nice!
But why are u using
key = lambda x: abs(x)
instead of
key=abs
More
Nice Approach, but cutting down the length of line 2 would have been a good idea.
More
The task description is very precise here:
> Here you should find the length of the longest substring that consists of the **same letter**.
The regex token `.` matches any single character except for line separators, so if the tests will be updated to check something like this:
assert long_re
More
A nice approach of **not** using _str.count()_
More
Hmmm, I was expecting something more special, but I should have known better. :D
More
Calling _filter_, which calls a lambda, which calls _bin()_...
Why not an if statement in the generator?
''.join(chr(c>>1) for c in message if not bin(b).count('1') & 1
More
Okay...
Now think about this:
for x in data[:]:
if data.count(x) == 1:
data.remove(x)
return data
More
Very nice and clear.
Just one small thing: Instead of using this:
wall.strip().split('\n')
it would be more readable and simpler to use `str.split()`:
wall.strip().split('\n')
By default `str.split()` splits at any whitespace character and treats consecutive whitespace characters as a s
More
Learned something new - again!
If I got it wright, using functools.partial() makes most sense if you are actually planning to reuse
the partial object?
More