2941: 크로아티아 알파벳
# 2941: 크로아티아 알파벳
s = str(input())
croatia_alphabet = ['dz=', 'c=', 'c-', 'd-', 'lj', 's=', 'z=']
count = 0
for a in croatia_alphabet:
if a in s :
count += 1
s = s.replace(a, '')
count+=len(s)
print(count)
## 다시풀기, 'ljes=njak' 케이스가 안맞음 -> 'nj' 입력 안했음
s = str(input())
croatia_alphabet = ['dz=', 'c=', 'c-', 'd-', 'lj', 's=', 'z=', 'nj']
count = 0
for a in croatia_alphabet:
if a in s :
count += 1
s = s.replace(a, '')
count += len(s)
print(count)
### 다시풀기, 같은 문자가 나온다면 문제 발생 replace할때 여러 문자들이 없어지게 됨 -> 문자열.count로 가보자
s = str(input())
croatia_alphabet = ['dz=', 'c=', 'c-', 'd-', 'lj', 's=', 'z=', 'nj']
count = 0
for a in croatia_alphabet:
count += s.count(a)
s = s.replace(a, '')
count += len(s)
print(count)
#### 다시풀기, 크로아티아문자를 '*'로 대체해 나중에 글자 수를 반환, 근데 왜 위 답이 틀렸을까 (중복이 제거되서 1개로 카운트되었기 때문)
s = str(input())
croatia_alphabet = ['dz=', 'c=', 'c-', 'd-', 'lj', 's=', 'z=', 'nj']
for a in croatia_alphabet:
s = s.replace(a, '*')
print(len(s))
1316: 그룹 단어 체커
# 1316: 그룹 단어 체커
N = int(input())
count = 0
for _ in range(N):
s = str(input())
s_set = set(s)
for i in s_set :
if s.count(i) > 1 :
count += 0
else :
count += 1
'''
해당 알파벳이 이미 리스트에 있는데 리스트의 마지막 원소랑 다르면 그룹단어가 아님
'''
N = int(input())
count = []
for _ in range(N):
s = str(input())
alphabet_list = []
for i in s:
if i not in alphabet_list :
alphabet_list.append(i)
elif i in alphabet_list and i != alphabet_list[-1] :
count.append(0)
break
else :
continue
print(N-len(count))
'매일매일 (Everyday)' 카테고리의 다른 글
[BOJ] - 기본 수학 1 - (2) - Python (0) | 2021.12.06 |
---|---|
[BOJ] - 기본 수학 1 - (1) - Python (0) | 2021.12.03 |
[BOJ] - 문자열 - (1) - Python (0) | 2021.12.01 |
[BOJ] - 함수 - Python (0) | 2021.11.30 |
[BOJ] - 1차원 배열 단계-(2) - Python (0) | 2021.11.29 |