-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
yjhss
committed
May 3, 2023
1 parent
28d4d86
commit 03e2521
Showing
1 changed file
with
22 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
|
||
|
||
|