Problem p03854 (python)

Fixed submission:
import re

if re.match("(dream|dreamer|erase|eraser)*$", input()):
    print("YES")
else:
    print("NO")

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(2000)

def text_match_words(text, words):
	match_words = []
	for word in words:
		if word == text[:len(word)]:
			match_words.append(word)
	return match_words

def is_match_for(text, words):
	if "" == text: 
		return True
	else:
		match_words = text_match_words(text, words)
		if [] == match_words:
			return False
		else:
			return any([is_match_for(text[len(match_word):], words) for match_word in match_words])

words = ("dream", "dreamer", "erase", "eraser")

s = input()

if is_match_for(s, words):
	print("YES")
else:
	print("NO")

Buggy submission (verdict: Runtime Error):

sys.setrecursionlimit(2000)

def text_match_words(text, words):
	match_words = []
	for word in words:
		if word == text[:len(word)]:
			match_words.append(word)
	return match_words

def is_match_for(text, words):
	if "" == text: 
		return True
	else:
		match_words = text_match_words(text, words)
		if [] == match_words:
			return False
		else:
			return any([is_match_for(text[len(match_word):], words) for match_word in match_words])

words = ("dream", "dreamer", "erase", "eraser")

s = input()

if is_match_for(s, words):
	print("YES")
else:
	print("NO")

Buggy submission (verdict: Runtime Error):

def text_match_words(text, words):
	match_words = []
	for word in words:
		if word == text[:len(word)]:
			match_words.append(word)
	return match_words

def is_match_for(text, words):
	if "" == text: 
		return True
	else:
		match_words = text_match_words(text, words)
		if [] == match_words:
			return False
		else:
			return any([is_match_for(text[len(match_word):], words) for match_word in match_words])

if is_match_for(input(), ("dream", "dreamer", "erase", "eraser")):
	print("YES")
else:
	print("NO")

Buggy submission (verdict: Runtime Error):
def text_match_words(text, words):
	match_words = []
	for word in words:
		if word == text[:len(word)]:
			match_words.append(word)
	return match_words

def is_match_for(text, words):
	if "" == text: 
		return True
	else:
		match_words = text_match_words(text, words)
		if [] == match_words:
			return False
		else:
			return any([is_match_for(text[len(match_word):], words) for match_word in match_words])

words = ("dream", "dreamer", "erase", "eraser")

s = input()

if is_match_for(s, words):
	print("YES")
else:
	print("NO")

Buggy submission (verdict: Runtime Error):
def text_match_words(text, words):
	match_words = []
	for word in words:
		if word == text[:len(word)]:
			match_words.append(word)
	return match_words

def is_match_for(text, words):
	if "" == text: 
		return True
	else:
		match_words = text_match_words(text, words)
		if [] == match_words:
			return False
		else:
			return any([is_match_for(text[len(match_word):], words) for match_word in match_words])

if __name__ == "__main__":
	words = ("dream", "dreamer", "erase", "eraser")

	s = input()

	if is_match_for(s, words):
		print("YES")
	else:
		print("NO")

Buggy submission (verdict: Runtime Error):
def text_match_words(text, words):
	match_words = []
	for word in words:
		if word == text[:len(word)]:
			match_words.append(word)
	return match_words

def is_match_for(text, words):
	if "" == text: 
		return True
	else:
		match_words = text_match_words(text, words)
		if [] == match_words:
			return False
		else:
			return any([is_match_for(text[len(match_word):], words) for match_word in match_words])

words = ("dream", "dreamer", "erase", "eraser")

s = input()

if is_match_for(s, words):
	print("YES")
else:
	print("NO")

Buggy submission (verdict: Runtime Error):
def text_match_words(text, words):
	match_words = []
	for word in words:
		if word == text[:len(word)]:
			match_words.append(word)
	return match_words

def is_match_for(text, words):
	if "" == text: 
		return True
	else:
		match_words = text_match_words(text, words)
		if [] == match_words:
			return False
		else:
			return any([is_match_for(text[len(match_word):], words) for match_word in match_words])
		
s = input()

words = ("dream", "dreamer", "erase", "eraser")

if is_match_for(s, words):
	print("YES")
else:
	print("NO")

Buggy submission (verdict: Runtime Error):
def text_match_words(text, words):
	match_words = []
	for word in words:
		if word == text[:len(word)]:
			match_words.append(word)
	return match_words

def is_match_for(text, words):
	if "" == text: 
		return True
	else:
		match_words = text_match_words(text, words)
		if [] == match_words:
			return False
		else:
			return any([is_match_for(text[len(match_word):], words) for match_word in match_words])
		
s = input()

words = ("dream", "dreamer", "erase", "eraser")

if is_match_for(s, words):
	print("YES")
else:
	print("NO")