https://programmers.co.kr/learn/courses/30/lessons/17686
코딩테스트 연습 - [3차] 파일명 정렬
파일명 정렬 세 차례의 코딩 테스트와 두 차례의 면접이라는 기나긴 블라인드 공채를 무사히 통과해 카카오에 입사한 무지는 파일 저장소 서버 관리를 맡게 되었다. 저장소 서버에는 프로그램��
programmers.co.kr
# [3차] 파일명 정렬
all_files = []
def solution(files):
answer = []
for one_file in files:
origin_file_name = one_file
file_head = ''
file_number = ''
checking_index = 0
while checking_index <= len(one_file) - 1 \
and not one_file[checking_index].isdigit():
file_head += one_file[checking_index]
checking_index += 1
number_length_check = 0
while checking_index <= len(one_file) - 1 \
and number_length_check <= 5 \
and one_file[checking_index].isdigit():
file_number += one_file[checking_index]
checking_index += 1
number_length_check += 1
all_files.append([file_head, int(file_number), origin_file_name])
sorted_files = sorted(all_files, key=lambda x: (x[0].lower(), x[1]))
answer = [file[2] for file in sorted_files]
return answer
'Problem-solving > 프로그래머스' 카테고리의 다른 글
프로그래머스 - (2020 카카오 인턴십) 키패드 누르기 (Python3) (0) | 2020.08.01 |
---|---|
프로그래머스 - (2019 카카오 개발자 겨울 인턴십) 크레인 인형뽑기 게임(Python3) (0) | 2020.08.01 |
프로그래머스 - (2018 KAKAO BLIND RECRUITMENT) [3차] 압축 (Python3) (0) | 2020.07.13 |
프로그래머스 - (2018 KAKAO BLIND RECRUITMENT) [3차] 방금그곡 (Python3) (2) | 2020.06.26 |
프로그래머스 - (2019 KAKAO BLIND RECRUITMENT) 후보키 (Python3) (0) | 2020.05.31 |
댓글