본문 바로가기
python-algorithm

백준 25773 Number Maximization

by 무적김두칠 2022. 12. 8.

https://www.acmicpc.net/problem/25773

 

25773번: Number Maximization

There is only one input line; it contains an integer between 0 and 999,999 (inclusive). Assume that the input number will not have leading 0’s. Note, however, that the input can be just the value 0.

www.acmicpc.net

 

1
2
3
4
5
6
7
def sol(s):
    answer = ''.join(sorted(s,reverse=True))
    return answer
 
if __name__ == '__main__':
    s = input()
    print(sol(s))
cs

sorted 함수(with reverse)를 통해 숫자를 큰 순서대로 정렬하고
join 함수로 리스트에서 문자열로 만들어 return합니다.

Sort the numbers descendingly using sorted function with reverse
and Type cast list to string with join function

반응형

'python-algorithm' 카테고리의 다른 글

백준 14912 숫자 빈도수  (0) 2022.12.10
백준 15719 중복된 숫자  (0) 2022.12.08
백준 26040 특정 대문자를 소문자로 바꾸기  (0) 2022.12.07
백준 6976 Divisibility by 11  (0) 2022.12.07
백준 5940 Math Practice  (0) 2022.12.07

댓글