Skip to content
Open
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions 8주차/14906/14906_python_yaho.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import re

slump_rex = re.compile('([DE]F+)+G')


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


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

print('SLURPYS OUTPUT')
for str in arr:
if not list(slump_rex.finditer(str)):
print('NO')
continue
s, e = list(slump_rex.finditer(str))[-1].span()
if e == len(str) and is_slimp(str[:s]):
print('YES')
else:
print('NO')
print('END OF OUTPUT')