Algorithm

[소프티어] 8단 변속기

쑤야. 2024. 1. 29. 10:44

https://softeer.ai/practice/6283

 

Softeer - 현대자동차그룹 SW인재확보플랫폼

 

softeer.ai

 

접근


  • 1부터 8까지 숫자가 한번씩 등장
    → 특이 케이스를 고려하지 않아도 된다
  • 연속적으로 변속하는 지 점검
    → 연속 배열을 하나 생성하고, 동일한지 여부 확인

 

코드


import sys
input = sys.stdin.readline()

data = list(map(int,input.split()))
g = [i+1 for i in range(8)]

if g == data:
    print("ascending")
elif sorted(g,reverse=True) == data:
    print("descending")
else:
    print("mixed")