Skip to content

Commit

Permalink
코테준비
Browse files Browse the repository at this point in the history
  • Loading branch information
sunho1999 committed May 29, 2024
1 parent d6ac3e0 commit 59a6327
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions Baekjoon_file/17609.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
testcase = int(input())

for i in range(testcase):
text = input()
left_idx = 0
right_idx = len(text)-1
chance = True
check = True
while(left_idx <= right_idx):
if check == False:
break
# print(left_idx,right_idx)
if text[left_idx] == text[right_idx]: # 왼쪽 오른쪽 같을 경우
left_idx +=1
right_idx -=1
else: # 왼쪽 오른쪽 다를 경우
if left_idx < right_idx - 1: # 인덱스 확인하기
temp = text[:right_idx] + text[right_idx + 1:]
if temp[:] == temp[::-1]:
chance = False
break
# 왼쪽 문자열 제거
if left_idx + 1 < right_idx:
temp = text[:left_idx] + text[left_idx + 1:]
if temp[:] == temp[::-1]:
chance = False
break
check = False
break
if check == False:
print(2)
elif check == True and chance == False:
print(1)
elif check== True and chance == True:
print(0)

0 comments on commit 59a6327

Please sign in to comment.