[백준/파이썬] 16337번 풀이
업데이트:
문제 정보
- 문제 출처: 백준 온라인 저지
- 문제 링크: 16337번 문제
- 문제풀이 코드 GitHub 링크
- 제출 언어: Python 3
풀이
문제
The boss of Binary Casino wants to have control over games played in his casino. This is especially true in the case of dice games, as from time to time people try to cheat their way to the victory by manipulating dice even after a throw has already occurred. Therefore, there is a camera installed to monitor the course of every single dice game. …
입력 요약
The input specifies the top side of a captured die. It consists of three lines, each with three characters “o” or “:” representing a dent or a smooth surface, respectively
출력 요약
Output a single line with either the number represented by the captured top side of the die or “unknown” if the image is incorrect.
코드
dice={"::::o::::":1,\
"o:::::::o":2,\
"::o:::o::":2,\
"o:::o:::o":3,\
"::o:o:o::":3,\
"o:o:::o:o":4,\
"o:o:o:o:o":5,\
"ooo:::ooo":6,\
"o:oo:oo:o":6}
try:
val=dice[input()+input()+input()]
except:
val="unknown"
print(val)
설명
핵심은 구현 관점에서 The boss of Binary Casino wants to have control over games played in his casino. …를 만족하도록 로직을 구성하는 것입니다.
코드는 입력을 파싱한 뒤 조건 분기와 계산을 순서대로 수행하고, 문제에서 요구한 형식으로 결과를 출력합니다.
경계값과 예외 케이스도 함께 고려해 오답이 나기 쉬운 상황을 방지합니다.
댓글남기기