[Python/ํŒŒ์ด์ฌ] [๐Ÿฅˆ5] ๋ฐฑ์ค€ ์•Œ๊ณ ๋ฆฌ์ฆ˜ 1427 - ์†ŒํŠธ์ธ์‚ฌ์ด๋“œ

keyneneยท2022๋…„ 10์›” 13์ผ
0

Python

๋ชฉ๋ก ๋ณด๊ธฐ
4/26
post-custom-banner

๐Ÿ“–[Python/ํŒŒ์ด์ฌ][๐Ÿฅˆ5] ๋ฐฑ์ค€ ์•Œ๊ณ ๋ฆฌ์ฆ˜ 1427 - ์†ŒํŠธ์ธ์‚ฌ์ด๋“œ

๐Ÿ“œ๋ฌธ์ œ



๐Ÿ“•ํ’€์ด๋ฐฉํ–ฅ

์ˆซ์ž๋ฅผ ์ˆœ์„œ๋Œ€๋กœ ์ •๋ ฌํ•ด์•ผํ•˜๋ฏ€๋กœ str()๋กœ ๋ฐ›์•˜๋‹ค๊ฐ€ map()์œผ๋กœ int๋กœ ๋ณ€๊ฒฝํ•˜์—ฌ list๋กœ ์ €์žฅํ•˜์ž
sort(key=lambda x:-x)๋ฅผ ์ด์šฉํ•˜์—ฌ ๋‚ด๋ฆผ์ฐจ์ˆœ ์ •๋ ฌํ•˜๊ณ ,
print()์˜ end=''๋ฅผ ์ด์šฉํ•˜์—ฌ ๊ณต๋ฐฑ(\n)์—†์ด ์ถœ๋ ฅํ•˜์ž


๐Ÿ“์•Œ๊ณ ๋ฆฌ์ฆ˜ ๊ตฌํ˜„์ˆœ์„œ

  1. ์ž…๋ ฅ๋ฐ›์Œ โ†’ str()๋กœ ๋ฌธ์ž๋กœ ๋ณ€๊ฒฝ โ†’ map(int,)๋กœ ์ •์ˆ˜์œผ๋กœ ๋ณ€๊ฒฝ โ†’ list()๋กœ ์ €์žฅ
  2. sort์˜ key๋ฅผ ์ด์šฉํ•˜์—ฌ ๋‚ด๋ฆผ์ฐจ์ˆœ ์ •๋ ฌ
  3. print ์˜ต์…˜ ์ด์šฉํ•˜์—ฌ "\n"๋–ผ๊ณ  ์ถœ๋ ฅ

๐Ÿ’ป๊ฒฐ๊ณผ์ฝ”๋“œ

n = list(map(int,str(input())))
n.sort(key=lambda x:-x)
for i in n:
    print(i,end='')
profile
keynene
post-custom-banner

0๊ฐœ์˜ ๋Œ“๊ธ€