SWEA

[SWEA] 20019. 회문의 회문 (Python)

가은(JANE) 2024. 11. 16. 23:36

#Problem

https://swexpertacademy.com/main/code/problem/problemDetail.do?problemLevel=2&problemLevel=3&contestProbId=AY2hjCWKbykDFATh&categoryId=AY2hjCWKbykDFATh&categoryType=CODE&problemTitle=&orderBy=FIRST_REG_DATETIME&selectCodeLang=ALL&select-1=3&pageSize=10&pageIndex=1

 

SW Expert Academy

SW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요!

swexpertacademy.com

 

#Think

  • 조건문 덕지덕지면 뭐든 풀 수 있다!

#Code

T=int(input())

for tc in range(1,T+1):
    s = list(input())
    #1번 조건
    re_s = s[::-1]
    n= len(s)
    number = int((n-1)/2)

    if s == re_s:
        # 2번 조건
        second = s[0:number]
        resecond = second[::-1]
        
        if second == resecond:
        	#3번 조건
            third = s[n-number:]
            rethird = third[::-1]
            
            if third == rethird:
                print(f"#{tc} YES")
            else: print(f"#{tc} NO")
        else : print(f"#{tc} NO")
    else: print(f"#{tc} NO")