백준 23304번: 아카라카 #Python

ColorlessDia·2024년 6월 27일

algorithm/baekjoon

목록 보기
220/836
def is_palindrome(word):
    half = int(len(word) / 2)

    if half == 0:
        return True

    prefix = word[:half]
    suffix = word[-half:]

    if prefix == suffix[::-1]:
        return is_palindrome(prefix)
    else:
        return False

S = input()

if is_palindrome(S):
    print('AKARAKA')
else:
    print('IPSELENTI')

0개의 댓글