Skip to content

Commit

Permalink
#14 : 1431_시리얼 번호
Browse files Browse the repository at this point in the history
  • Loading branch information
yjhss committed May 3, 2023
1 parent 28d4d86 commit 03e2521
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions 이티유진/1431_시리얼 번호.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import sys

n = int(sys.stdin.readline()) #기타 개수 n 입력
s = [input() for i in range(n)] #시리얼 번호 n개 입력

#정렬 2_자릿수 합
def sum(x):
r = 0
for i in x:
if i.isdigit(): #isdigit(): 문자열이 숫자인지 판별
r += int (i)
return r

#정렬_ 1.길이 2.자릿수 합 3.사전순
s.sort(key = lambda x: (len(x), sum(x), x))

#정렬된 리스트 s의 모든 요소 출력
for i in s:
print(i)



0 comments on commit 03e2521

Please sign in to comment.