[백준/파이썬] 16408번 풀이
업데이트:
문제 정보
- 문제 출처: 백준 온라인 저지
- 문제 링크: 16408번 문제
- 문제풀이 코드 GitHub 링크
- 제출 언어: Python 3
풀이
문제
You are given a five-card hand drawn from a standard 52-card deck. The strength of your hand is the maximum value k such that there are k cards in your hand that have the same rank.
Compute the strength of your hand.
입력 요약
The input will consist of a single line, with five two-character strings separated by spaces.
The first character in each string will be the rank of the card, and will be one of A23456789TJQK. …
출력 요약
Output, on a single line, the strength of your hand.
코드
l=input().split()
d={}
for i in l:
try:d[i[0]]+=1
except:d[i[0]]=1
print(max(d.values()))
설명
핵심은 구현 관점에서 You are given a five-card hand drawn from a standard 52-card deck. The strength of your hand is the maximum value k such that there are k cards in you …를 만족하도록 로직을 구성하는 것입니다.
코드는 입력을 파싱한 뒤 조건 분기와 계산을 순서대로 수행하고, 문제에서 요구한 형식으로 결과를 출력합니다.
경계값과 예외 케이스도 함께 고려해 오답이 나기 쉬운 상황을 방지합니다.
댓글남기기