11
Jonathan Rhau
Last seen 1 year ago
Member for 4 years, 6 months
Difficulty Normal
Thanks to this, I have deepen my understanding of the sorted function!!! This is genius!
More
this is nice, but I don't understand why you use ```len(items) - items.count(x)```.
I guess it is to reverse the order of the sort?
More
You just made me learn about the ord and chr function! Thanks ;)
More
Trying to process this because it's beautiful!
If I understand this, you basically sort base on a tuple compose of the negative count ( trick to reverse the order) and of the index position.
So if we take the example ```[4, 6, 2, 2, 6, 4, 4, 4]```
================================================
More
Nice! I was looking for a way to add the None requirement in a one liner and you did it!
More
I put alot of comments, but the code is not that long.
def checkio(text: str) -> str:
stats = {}
text = text.lower()
for c in set(text):
if c.isalpha():
if stats.get(text.count(c)):
stats[text.count(c)].append(c)
else:
More
Make sense of defining the alphabet instead of doing for 'c in text' because the alphabet is known and finite
More
the only variable we need to extract is the hour since the rest remain unchanged, so decided to go with slicing.
using the absolute value of h-12 to tackle midnight vs noon case in one clean action.
Tried to make it shorter using lambda, but felt readability took too much of a hit
More