Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in 3rd party category for Three Words by AlexXu1225
import numpy as np
import re
def checkio(words: str) -> bool:
# find the index of words
# use np.diff and re to check succession
index_gap = np.diff([i for i,w in enumerate(words.split(' ')) if w.isalpha()])
index_str = ''.join([str(j) for j in index_gap])
pattern = re.compile(r'11')
return len(re.findall(pattern, index_str))>0
#These "asserts" using only for self-checking and not necessary for auto-testing
if __name__ == '__main__':
print('Example:')
print(checkio("Hello World hello"))
assert checkio("Hello World hello") == True, "Hello"
assert checkio("He is 123 man") == False, "123 man"
assert checkio("1 2 3 4") == False, "Digits"
assert checkio("bla bla bla bla") == True, "Bla Bla"
assert checkio("Hi") == False, "Hi"
print("Coding complete? Click 'Check' to review your tests and earn cool rewards!")
Jan. 6, 2021
Comments: