[백준/파이썬] 10551번 풀이
업데이트:
문제 정보
- 문제 출처: 백준 온라인 저지
- 문제 링크: 10551번 문제
- 문제풀이 코드 GitHub 링크
- 제출 언어: Python 3
풀이
문제
Proper typing is becoming an essential part of culture. If you are still not using all ten fingers for typing, you have to re-learn typing – then you will type faster and feel more comfortable and enjoyable.
There are a lot of web sites teaching proper typing. The following image depicts the basic principle; the keys needed to press with the same finger are of the same color. The yellow keys need to be pressed with the pinky, the blue ones with the ring finger, the green ones with the middle finger and the red ones with the index finger. …
입력 요약
The first and only line of input contains of a string consisting of at least one and at most fifty characters. The string doesn’t contain whitespaces and consists only of characters depicted on the image above.
출력 요약
The output must consist of eight lines, in each line one integer denoting the number of presses of each finger, excluding thumbs, observed from left to right.
코드
s = input()
finger=dict()
finger[1]=['`', '1', 'Q', 'A', 'Z']
finger[2]=['2', 'W', 'S', 'X']
finger[3]=['3', 'E', 'D', 'C']
finger[4]=['4', 'R', 'F', 'V', '5', 'T', 'G', 'B']
finger[5]=['6', 'Y', 'H', 'N', '7', 'U', 'J', 'M']
finger[6]=['8', 'I', 'K', ',']
finger[7]=['9', 'O', 'L', '.']
finger[8]=['0', 'P', ';', '/', '-', '[', "'", '=', ']']
count = {i:0 for i in range(1, 9)}
for c in s:
for i in range(1, 9):
if c in finger[i]:
count[i] += 1
break
print("\n".join(map(str, count.values())))
설명
핵심은 구현 관점에서 Proper typing is becoming an essential part of culture. If you are still not using all ten fingers for typing, you have to re-learn typing – then you …를 만족하도록 로직을 구성하는 것입니다.
코드는 입력을 파싱한 뒤 조건 분기와 계산을 순서대로 수행하고, 문제에서 요구한 형식으로 결과를 출력합니다.
경계값과 예외 케이스도 함께 고려해 오답이 나기 쉬운 상황을 방지합니다.
댓글남기기