Skip to content

Commit

Permalink
#9 9342번 염색체
Browse files Browse the repository at this point in the history
  • Loading branch information
leejw-lu committed Mar 13, 2024
1 parent 4a1e9de commit 2cfe84a
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions 문자열/9342_염색체.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# 정규표현식
# ^ 해당 패턴으로 시작
# ? 해당 패턴을 0번또는 1번
# $ 해당 패턴으로 끝
# + 해당 패턴이 하나 이상
#
# import re
# p=re.compile('^[A-F]?A+F+C+[A-F]?$')
# N = int(input())
# for _ in range(N):
# k = input()
# if p.fullmatch(k):
# print('Infected!')
# else:
# print('Good')

####
t=int(input())
for _ in range(t):
ss=input()

result='Infected!'
checks=['A','B','C','D','E','F']
pre=''
if ss[0] not in checks or ss[-1] not in checks:
result='Good'
else:
checks=['A','F','C']
index=0
pre='A'
for s in ss[1:-1]:
if pre!=s:
index+=1
if checks[index]!=s:
result='Good'
break
pre=s
print(result)

1 comment on commit 2cfe84a

@leejw-lu
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

정규표현식의 문제인 것 같다. 정규표현식도 알아놓으면 좋을듯...

Please sign in to comment.