프로그래머스/LV2
[프로그래머스 Lv2, python] - 마법의 엘리베이터
chyam_eun
2025. 3. 3. 13:48
https://school.programmers.co.kr/learn/courses/30/lessons/148653#
프로그래머스
SW개발자를 위한 평가, 교육, 채용까지 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프
programmers.co.kr
def solution(storey):
cnt = 0 # 버튼 누르는 수
while(storey>0):
num=storey%10
storey//=10
if num>5: # 맨 뒷자리가 5보다 클때
storey+=1 # 자릿수 올려주기
cnt+=10-num
elif num==5: # 5일때
if storey%10<5: # 앞이 5 미만일때
cnt+=10-num
else: # 앞이 5 이상일때
storey+=1 # 자릿수 올려주기
cnt+=num
else: # 5 미만일때
cnt+=num
return cnt