Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Uncategorized category for Stressful Subject by Rounin
import re
def is_stressful(subj):
words = ['help','asap','urgent']
for i in range(len(words)):
word = ''
for char in words[i]:
word += char + '[^' + ('' if char == 'a' else 'a-'+chr(ord(char)-1)) + ('' if char == 'z' else chr(ord(char)+1)+'-z') +']*'
words[i] = word
for word in words:
if re.match('.*'+word+'.*', subj.lower()) != None:
return True
return subj[len(subj)-3:len(subj)] == '!!!' or subj.upper() == subj
if __name__ == '__main__':
#These "asserts" using only for self-checking and not necessary for auto-testing
assert is_stressful("Hi") == False, "First"
assert is_stressful("I neeed HELP") == True, "Second"
print('Done! Go Check it!')
July 20, 2017