본문 바로가기
알고리즘

[Softeer level2] Python 8단변속기

by 돌맹96 2023. 8. 8.
728x90
반응형

Softeer

 

Softeer

연습문제를 담을 Set을 선택해주세요. 취소 확인

softeer.ai

문제

현대자동차에서는 부드럽고 빠른 변속이 가능한 8단 습식 DCT 변속기를 개발하여 N라인 고성능차에 적용하였다. 관련하여 SW 엔지니어인 당신에게 연속적으로 변속이 가능한지 점검할 수 있는 프로그램을 만들라는 임무가 내려왔다.

 

당신은 변속기가 1단에서 8단으로 연속적으로 변속을 한다면 ascending, 8단에서 1단으로 연속적으로 변속한다면 descending, 둘다 아니라면 mixed 라고 정의했다.

 

변속한 순서가 주어졌을 때 이것이 ascending인지, descending인지, 아니면 mixed인지 출력하는 프로그램을 작성하시오.

 

문제풀이

일단 주어진 배열에서 다른 배열을 만들어서 정렬을 한 후 두 값을 비교해보면 되는 문제이다.

import sys
import copy
input = sys.stdin.readline
speed = list(map(int, input().split()))
compare_speed = copy.deepcopy(speed)

if(speed == sorted(compare_speed, reverse=False)):
    print("ascending")
elif(speed == sorted(compare_speed, reverse=True)):
    print("descending")
else:
    print("mixed")

728x90
반응형