๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
4๏ธโƒฃ Python/Problem Solving

[Python Algorithm] ์ตœ๋Œ“๊ฐ’๊ณผ ์ตœ์†Ÿ๊ฐ’ Programmers(Lv.2)

by seolhee2750 2022. 2. 4.
๋ฌธ์ œ

https://programmers.co.kr/learn/courses/30/lessons/12939?language=python3 

 

์ฝ”๋”ฉํ…Œ์ŠคํŠธ ์—ฐ์Šต - ์ตœ๋Œ“๊ฐ’๊ณผ ์ตœ์†Ÿ๊ฐ’

๋ฌธ์ž์—ด s์—๋Š” ๊ณต๋ฐฑ์œผ๋กœ ๊ตฌ๋ถ„๋œ ์ˆซ์ž๋“ค์ด ์ €์žฅ๋˜์–ด ์žˆ์Šต๋‹ˆ๋‹ค. str์— ๋‚˜ํƒ€๋‚˜๋Š” ์ˆซ์ž ์ค‘ ์ตœ์†Œ๊ฐ’๊ณผ ์ตœ๋Œ€๊ฐ’์„ ์ฐพ์•„ ์ด๋ฅผ "(์ตœ์†Œ๊ฐ’) (์ตœ๋Œ€๊ฐ’)"ํ˜•ํƒœ์˜ ๋ฌธ์ž์—ด์„ ๋ฐ˜ํ™˜ํ•˜๋Š” ํ•จ์ˆ˜, solution์„ ์™„์„ฑํ•˜์„ธ์š”. ์˜ˆ๋ฅผ

programmers.co.kr

 

๋‚ด ๋ฌธ์ œ ํ’€์ด
def solution(s):
    num_s = list(map(int, s.split()))
    return str(min(num_s)) + " " + str(max(num_s))

๐Ÿ‘‰ ๊ตฌํ˜„ ๋ฌธ์ œ๋กœ, ๊ณต๋ฐฑ์„ ๊ธฐ์ค€์œผ๋กœ intํ˜• ๋ฆฌ์ŠคํŠธ๋กœ ๋ณ€ํ™˜ํ•˜์—ฌ max์™€ min์„ ๊ตฌํ•ด์ฃผ์—ˆ๋‹ค.

 

๐Ÿ’ก ํ”ผ๋“œ๋ฐฑ
  • ๋ฌธ์ž์—ด๊ณผ ์ˆซ์ž ์‚ฌ์ด์˜ ํ˜•๋ณ€ํ™˜์„ ์ž์œ ๋กญ๊ฒŒ ํ•  ์ˆ˜ ์žˆ์œผ๋ฉด ์‰ฝ๊ฒŒ ํ’€ ์ˆ˜ ์žˆ๋Š” ๋ฌธ์ œ์˜€๋‹ค.

๋Œ“๊ธ€