Skip to content

Commit 59a6327

Browse files
committed
코테준비
1 parent d6ac3e0 commit 59a6327

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

Baekjoon_file/17609.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
testcase = int(input())
2+
3+
for i in range(testcase):
4+
text = input()
5+
left_idx = 0
6+
right_idx = len(text)-1
7+
chance = True
8+
check = True
9+
while(left_idx <= right_idx):
10+
if check == False:
11+
break
12+
# print(left_idx,right_idx)
13+
if text[left_idx] == text[right_idx]: # 왼쪽 오른쪽 같을 경우
14+
left_idx +=1
15+
right_idx -=1
16+
else: # 왼쪽 오른쪽 다를 경우
17+
if left_idx < right_idx - 1: # 인덱스 확인하기
18+
temp = text[:right_idx] + text[right_idx + 1:]
19+
if temp[:] == temp[::-1]:
20+
chance = False
21+
break
22+
# 왼쪽 문자열 제거
23+
if left_idx + 1 < right_idx:
24+
temp = text[:left_idx] + text[left_idx + 1:]
25+
if temp[:] == temp[::-1]:
26+
chance = False
27+
break
28+
check = False
29+
break
30+
if check == False:
31+
print(2)
32+
elif check == True and chance == False:
33+
print(1)
34+
elif check== True and chance == True:
35+
print(0)

0 commit comments

Comments
 (0)