백준 6764 Sounds fishy!
문제
A fish-finder is a device used by anglers to find fish in a lake. If the fish-finder finds a fish, it will sound an alarm. It uses depth readings to determine whether to sound an alarm. For our purposes, the fish-finder will decide that a fish is swimming past if:
- there are four consecutive depth readings which form a strictly increasing sequence (such as 3 4 7 9) (which we will call “Fish Rising”), or
- there are four consecutive depth readings which form a strictly decreasing sequence (such as 9 6 5 2) (which we will call “Fish Diving”), or
- there are four consecutive depth readings which are identical (which we will call “Constant Depth”).
All other readings will be considered random noise or debris, which we will call “No Fish.”
Your task is to read a sequence of depth readings and determine if the alarm will sound.
입력
The input will be four positive integers, representing the depth readings. Each integer will be on its own line of input.
출력
The output is one of four possibilities. If the depth readings are increasing, then the output should be Fish Rising. If the depth readings are decreasing, then the output should be Fish Diving. If the depth readings are identical, then the output should be Fish At Constant Depth. Otherwise, the output should be No Fish.
예제 입력 1
1
10
12
13
예제 출력 1
Fish Rising
풀이 과정
값이 연속으로 작아지는지, 커지는지, 전부 같은지 파악한다.
코드
depth = []
for _ in range(4):
depth.append(int(input()))
result = ''
if depth[0] < depth[1] < depth[2] < depth[3]:
result = 'Fish Rising'
elif depth[0] > depth[1] > depth[2] > depth[3]:
result = 'Fish Diving'
elif depth[0] == depth[1] == depth[2] == depth[3]:
result = 'Fish At Constant Depth'
else:
result = 'No Fish'
print(result)
Author And Source
이 문제에 관하여(백준 6764 Sounds fishy!), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://velog.io/@mynote/백준-6764-Sounds-fishy저자 귀속: 원작자 정보가 원작자 URL에 포함되어 있으며 저작권은 원작자 소유입니다.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)