Skip to content

Commit

Permalink
Merge pull request #124 from AlgoLeadMe/33-Dolchae
Browse files Browse the repository at this point in the history
33-Dolchae
  • Loading branch information
Dolchae authored Mar 8, 2024
2 parents d0e7d1a + 0df227a commit c43f1b9
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Dolchae/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,5 @@
| 29์ฐจ์‹œ| 2024.02.19 | ๋ธŒ๋ฃจํŠธํฌ์Šค | [2961 ๋„์˜์ด๊ฐ€ ๋งŒ๋“  ๋ง›์žˆ๋Š” ์Œ์‹](https://www.acmicpc.net/problem/2961) | [#109](https://github.com/AlgoLeadMe/AlgoLeadMe-3/pull/109) |
| 30์ฐจ์‹œ| 2024.02.22 | DFS | [2644 ์ดŒ์ˆ˜๊ณ„์‚ฐ](https://www.acmicpc.net/problem/2644) | [#112](https://github.com/AlgoLeadMe/AlgoLeadMe-3/pull/112) |
| 31์ฐจ์‹œ| 2024.02.27 | ๊ตฌํ˜„ | [13414 ์ˆ˜๊ฐ•์‹ ์ฒญ](https://www.acmicpc.net/problem/13414) | [#117](https://github.com/AlgoLeadMe/AlgoLeadMe-3/pull/117) |
| 32์ฐจ์‹œ| 2024.02.29 | ๊ทธ๋ฆฌ๋”” | [2012 ๋“ฑ์ˆ˜ ๋งค๊ธฐ๊ธฐ](https://www.acmicpc.net/problem/13414) | [#119](https://github.com/AlgoLeadMe/AlgoLeadMe-3/pull/119) |
| 32์ฐจ์‹œ| 2024.02.29 | ๊ทธ๋ฆฌ๋”” | [2012 ๋“ฑ์ˆ˜ ๋งค๊ธฐ๊ธฐ](https://www.acmicpc.net/problem/2012) | [#119](https://github.com/AlgoLeadMe/AlgoLeadMe-3/pull/119) |
| 33์ฐจ์‹œ| 2024.03.04 | ์ •๋ ฌ | [1431 ์‹œ๋ฆฌ์–ผ ๋ฒˆํ˜ธ](https://www.acmicpc.net/problem/1431) | [#124](https://github.com/AlgoLeadMe/AlgoLeadMe-3/pull/124) |
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import sys
input = sys.stdin.readline

n = int(input().strip())
serial = []

for _ in range(n):
serial.append(input().strip())

def get_number_sum(s):
number_sum = 0
for char in s:
if char.isdigit():
number_sum += int(char)
return number_sum

for i in range(n-1):
for j in range(i+1, n):
if len(serial[i]) > len(serial[j]):
serial[j], serial[i] = serial[i], serial[j]
elif len(serial[i]) == len(serial[j]):
i_total = get_number_sum(serial[i])
j_total = get_number_sum(serial[j])
if i_total > j_total:
serial[j], serial[i] = serial[i], serial[j]
elif i_total == j_total:
if serial[i] > serial[j]:
serial[j], serial[i] = serial[i], serial[j]

for i in serial:
print(i)

0 comments on commit c43f1b9

Please sign in to comment.