728x90
https://www.acmicpc.net/problem/1431
1431번: 시리얼 번호
첫째 줄에 기타의 개수 N이 주어진다. N은 50보다 작거나 같다. 둘째 줄부터 N개의 줄에 시리얼 번호가 하나씩 주어진다. 시리얼 번호의 길이는 최대 50이고, 알파벳 대문자 또는 숫자로만 이루어
www.acmicpc.net
import sys
input = sys.stdin.readline
def compare(inputs):
ans = 0
for i in inputs:
if i.isdigit():
ans += int(i)
return ans
num = list()
N = int(input())
for i in range(N):
M = input().rstrip()
num.append(M)
num.sort(key = lambda x : (len(x), compare(x), x))
for i in num:
print(i)
728x90
'Study > Coding Test' 카테고리의 다른 글
[백준] 2346 - 풍선 터뜨리기 Python (0) | 2023.10.09 |
---|---|
[프로그래머스] 구명보트 Python (0) | 2023.09.28 |
[백준] 21608 - 상어 초등학교 Python (0) | 2023.08.11 |
[백준] 1967 - 트리의 지름 Python (0) | 2023.08.09 |
[프로그래머스] 가장 큰 수 Python (0) | 2023.08.09 |