14
Last seen 7 years ago
Member for 8 years, 7 months, 11 days
Difficulty Normal
Great to know that set.intersection() can accept any iterable. Thank you!
More
Nice solution. But you might make it a couple lines shorter:
put safe_pawn.append(pawn) directly under if gaurdy + gaurdx in pawns.
So you don't need the variable safe anymore.
Also, keeping the safe pawns in a list seems to incur redundant memory usage. Keep a int variable count and += 1 when safe
More
Stolen from:
http://www.checkio.org/mission/three-words/publications/LLluma/python-3/first/
More
similar but without islice:
def checkio(words):
return any(all(map(unicode.isalpha, trigram)) for trigram in zip(*(words.split()[i:] for i in range(3))))
http://www.checkio.org/mission/three-words/publications/hezhe88/python-27/second/
More
If anyone is also wondering how filter function eliminates zeros:
https://docs.python.org/2/library/functions.html#filter
"[item for item in iterable **if item**] if function is None."
More
This might be an O(nlogn) solution. Can you do it in O(n)?
More
Each time text.count(x) is called, it requires O(n) time. So the total running time will be O(n^2).
More