13
Last seen 1 year ago
Member for 2 years, 7 months, 17 days
Difficulty Normal
Nice solution! But maybe you can express this in a shorter way?
return t > f
does the same as
if t > f:
return True
else:
return False
Also, do the counted items really need to be stored in their own variables? You could just calculate them within the comparison like
More
Great solution! You can actually shorten it even further by using list comprehension:
for i in range(0, len(items), size):
yield items[i:i+size]
could become
yield [items[i:i+size] for i in range(0, len(items), size)]
thus being shorter and far more readable.
More
Great solution!
return False if items.count(False) >= items.count(True) else max(items)
does the same as
return items.count(False) <= items.count(True)
P.S. Don't forget to delete your print statements!
More
Great solution! But I think that should rather belong to the "clear" category, shouldn't it?
More
Great solution, clear and concise. But you missed some bonus points by not using a lambda and instead opting for def. Anyways, that's just my preference.
More
if len(items) == 0:
return items
if size > len(items):
return [items]
is actually not necessary, these edge-cases are taken care of by the range function (if you specify range(0, 0, 4) it would not return anything, thus generating an empty list).
Still, great solution!
More
Great solution! But maybe use a lambda? (just for bonus points, def actually works better in a production environment) :-)
More
Great solution! Maybe it could be shortened by using list comprehension?
result = []
if items != []:
for i in range(0,len(items),size):
result.append(list(items[i:i+size]))
return result
could become
[items[x:x+size] for x in range(0, len(items), size)]
More
That's a really short one! Well done, couldn't really add anything of value to that.
More
Looks good, but maybe use a lambda instead of def and return? Anyways, that's really clean an well-structured, good job!
More
Why have you set the variable password as the variable pw? You could just modify the def at the top if you don't want to have long variable names. And, while looping through a list of pw definitely works it isn't really as clean as using other methods like map() or any().
More