Cute Running Puppy

algorithm/[python] baekjoon

[python] 2941_크로아티아 알파벳

R.silver 2022. 2. 17. 21:10
반응형

https://www.acmicpc.net/problem/2941

 

2941번: 크로아티아 알파벳

예전에는 운영체제에서 크로아티아 알파벳을 입력할 수가 없었다. 따라서, 다음과 같이 크로아티아 알파벳을 변경해서 입력했다. 크로아티아 알파벳 변경 č c= ć c- dž dz= đ d- lj lj nj nj š s= ž z=

www.acmicpc.net

 

cro = ["c=", "c-", "dz=", "d-", "lj", "nj", "s=", "z="]
alpha = input()

for i in cro:
    if i in alpha:
        '''
        alpha = alpha.replace(i, '') 
        res += 1
        발견한 크로아티아 문자를 없애면
        중복된 크로아티아 문자를 셀 수 없다. 
        '''
        alpha = alpha.replace(i, "*") 
        # 두 글자 이상의 크로아티아 문자를 한번에 *로 변경하여 글자 수를 셀 수 있다.

print(len(alpha))

 

크로아티아 문자를 *로 변환하여 글자 수를 센다. 

if 문 작성에 주의하기 

반응형

'algorithm > [python] baekjoon' 카테고리의 다른 글

2667_단지번호붙이기  (0) 2023.04.24
[python] 5622_다이얼  (0) 2022.02.17
[python] 1712_손익분기점  (0) 2022.02.17
[python] 2292_벌집  (0) 2022.02.17
[python] 백준 2908_상수  (0) 2021.08.05