Skip to content

[레오] 8주차 과제 제출 #255

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
46 changes: 46 additions & 0 deletions 8주차/14906/14906_python_leo.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import re


def is_slurpy(word):
slump_regex = re.compile('([DE]F+)+G')
slump = list(slump_regex.finditer(word))
if not slump:
return False
start_index, end_index = slump[0].span()
if end_index == len(word) and is_slimp(word[:end_index]):
return True
return False


def is_slimp(word):
slump_regex = re.compile('([DE]F+)+G')
if word == 'AH':
return True
elif re.compile('AB[A-Z]+C').match(word) is not None:
return len(word) > 4 and is_slimp(word[2:-1])
elif re.compile('A[A-Z]+C').match(word) is not None:
return len(word) > 4 and (slump_regex.match(word[1:-1]) is not None)
return False


def solution(N, words):
answer = []
for word in words:
answer.append(is_slurpy(word))
return answer


def solution_word(is_true):
if is_true:
return "YES"
return "NO"


N = int(input())
words = [input() for _ in range(N)]


print('SLURPYS OUTPUT')
for i in solution(N, words):
print(solution_word(i))
print('END OF OUTPUT')