소스 코드

import sys
input = sys.stdin.readline().strip()

alpha = [
    'c=', 'c-', 'dz=', 'd-', 'lj', 'nj', 's=', 'z='
]
chk = ['c', 'd', 'l', 'n', 's', 'z']
word = input
cnt = 0
idx = 0
while idx < len(word):
    if word[idx] in chk:
        if word[idx:idx + 2] in alpha:
            cnt += 1
            idx += 2
        elif word[idx:idx + 3] in alpha:
            cnt += 1
            idx += 3
        else:
            cnt += 1
            idx += 1

    else:
        cnt += 1
        idx += 1

print(cnt)

 


해결 방법

 


느낀 점

 

 

ps. 개인적인 코드와 코드를 작성의 이유를 적은 것입니다.

 

오류적절치 않은 문법이 존재할 수 있으며, 다른 분들께는 굉장히 비효율적인 방법으로 여겨질 수 있습니다.

 

혹시 개선 사항, 오류 및 문제에 대한 수정 사항 등을 댓글로 남겨주신다면 감사한 마음으로 배우고 수정하겠습니다.