[백준/파이썬] 13234번 풀이

업데이트:



문제 정보


풀이

문제

George Boole was an English mathematician, educator, philosopher who was born in 1815, 200 years ago. He was the first professor of mathematics at Queen’s College, Cork (now University College Cork (UCC)) and is known as the inventor of boolean arithmetic: The field that is the basis of today’s computers.

In boolean arithmetic, instead of infinite numbers we only have 2 values: 0/1, true/false, yes/no, etc. We will use the values true and false in this problem. …

입력 요약
Read a single line from the standard input. The line will contain three words with the format:

value1 operation value2. The fields value1 and value2 will be either true or false. The field operation will be either AND or OR.

출력 요약
Print either true or false.

코드

a,b,c=input().split()
a=True if a=='true'else False
c=True if c=='true'else False
if b=='AND':print('true'if a and c else'false')
else:print('true'if a or c else'false')

설명

핵심은 구현 관점에서 George Boole was an English mathematician, educator, philosopher who was born in 1815, 200 years ago. …를 만족하도록 로직을 구성하는 것입니다.

코드는 입력을 파싱한 뒤 조건 분기와 계산을 순서대로 수행하고, 문제에서 요구한 형식으로 결과를 출력합니다.

경계값과 예외 케이스도 함께 고려해 오답이 나기 쉬운 상황을 방지합니다.



다음 읽을거리

관련 허브 페이지에서 같은 주제의 글을 이어서 확인할 수 있습니다.

댓글남기기