15
Last seen 2 years ago
Member for 10 years, 2 months, 20 days
Difficulty Normal
I was sure you would have found something in l.4:)
I do agree with the comment that treating boolean as int is less good than an equivalent without.
I did the following by using bool as bool
count = count + 1 if w[0].isalpha() else 0
More
This actually incorrect for large input. Use itertools.count() instead of range(0, 1000)
More
It is unreadable but wow, not even a loop.
Did you applied a known math formula?
More
sum(array[-1:] is an interesting way to avoid the empty array.
This is probably the shortest readable solution.
More
You can use endswith
Sorting before by len allow you to avoid the len comparison.
Note that by sorting lexical, you could even avoid a loop
More
1. You don't need the [] around the "
2. you can use () to select the words without the quotes
3. then you don't need to make a comprehension list:
return [elem[1:-1] for elem in re.findall(r'["][^"]*["]' , a)]
-->
return re.findall(r'"([^"]*)"' , a)
More
By sorting words by len, you can have just a triangle matrix path
By sorting lexical order, you can even avoid a search
More
I don't think this should be in speedy because you have to compute everything even if the three first elments are words.
More
I end up with the exact same solution. I guess it is the fastest possible one.
More