[PS] BOJ 33571 / 구멍
문제 링크: https://www.acmicpc.net/problem/33571
Thumbnail: Photo by Gabriel / Unsplash
풀이
구멍이 있는 문자의 경우만 미리 딕셔너리로 기록해 두고, 딕셔너리에 키가 없는 경우는 '구멍이 없다'고 판단해 전체 개수를 세도록 구현했다.
코드
circles = {
"A": 1, "a": 1,
"B": 2, "b": 1,
"D": 1, "d": 1,
"e": 1,
"g": 1,
"O": 1, "o": 1,
"P": 1, "p": 1,
"Q": 1, "q": 1,
"R": 1,
"@": 1
}
S = open(0).readline()
cnt = 0
for c in S:
if c in circles:
cnt += circles.get(c)
print(cnt)solution.py