관리 메뉴

솜씨좋은장씨

[BaekJoon] 6764번 : Sounds fishy! (Python) 본문

Programming/코딩 1일 1문제

[BaekJoon] 6764번 : Sounds fishy! (Python)

솜씨좋은장씨 2022. 9. 6. 02:20
728x90
반응형

코딩 1일 1문제! 오늘의 문제는 백준의 Sounds fishy! 입니다.

 

6764번: Sounds fishy!

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 b

www.acmicpc.net

👨🏻‍💻 코드 ( Solution )

def sounds_fishy(depth_info):
    answer = "No Fish"
    check_num = 0
    
    for idx in range(len(depth_info)-1):
        if depth_info[idx + 1] > depth_info[idx]:
            check_num += 1
        elif depth_info[idx + 1] < depth_info[idx]:
            check_num -= 1
            
    if len(set(depth_info)) == 1:
        answer = "Fish At Constant Depth"
    elif check_num == 3:
        answer = "Fish Rising"
    elif check_num == -3:
        answer = "Fish Diving"
        
    return answer


if __name__ == "__main__":
    depth_info = []
    
    for _ in range(4):
        depth = int(input())
        depth_info.append(depth)
        
    print(sounds_fishy(depth_info=depth_info))
 

GitHub - SOMJANG/CODINGTEST_PRACTICE: 1일 1문제 since 2020.02.07

1일 1문제 since 2020.02.07. Contribute to SOMJANG/CODINGTEST_PRACTICE development by creating an account on GitHub.

github.com

Comments