jungunshj   1년 전

반례좀 주세요 이것저것 다 해봤는데 다 맞게 나와요

djm03178   1년 전

"there are four consecutive depth readings which are identical (which we will call “Constant Depth”)."

"If the depth readings are identical, then the output should be Fish At Constant Depth."

jungunshj   1년 전

l = []

for i in range(4):

n = int(input())

l.append(n)

if len(set(l)) == 1:

print('Fish At Constant Depth')

elif sorted(l) == l:

print('Fish Rising')

elif sorted(l) == list(reversed(l)):

print('Fish Diving')

else:

print('No Fish')

djm03178   1년 전

추가 질문인가요? 상황을 이야기해주셔야 다음 답변을 드릴 수 있습니다. 그리고 코드는 밑에 소스 추가 버튼을 눌러 나오는 칸에 해주셔야 깨지지 않습니다.

코드상에는 다른 문제도 있네요. Fish Rising이나 Fish Diving이 되려면 각각 "strictly increasing sequence"와 "strictly decreasing sequence"여야 합니다. 즉, 같은 원소 없이 네 원소가 서로 모두 달라야 합니다.

jungunshj   1년 전

감사합니다

jungunshj   1년 전

잘 안되는것 같네요 집합으로 하면 중복이 없어야 하니까 맞지 않나요?

djm03178   1년 전

'정렬이 된 list'와 '정렬된 list를 바탕으로 만든 set'은 같지 않습니다.

댓글을 작성하려면 로그인해야 합니다.