์นดํ…Œ๊ณ ๋ฆฌ ์—†์Œ

ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค | ์ตœ๋Œ“๊ฐ’๊ณผ ์ตœ์†Ÿ๊ฐ’ โญ - Python

๐Ÿฉท ๋ฏผ์˜ 2024. 4. 5. 23:28

๐Ÿ—’๏ธ ๋ฌธ์ œ

https://school.programmers.co.kr/learn/courses/30/lessons/12939

 

ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค

์ฝ”๋“œ ์ค‘์‹ฌ์˜ ๊ฐœ๋ฐœ์ž ์ฑ„์šฉ. ์Šคํƒ ๊ธฐ๋ฐ˜์˜ ํฌ์ง€์…˜ ๋งค์นญ. ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค์˜ ๊ฐœ๋ฐœ์ž ๋งž์ถคํ˜• ํ”„๋กœํ•„์„ ๋“ฑ๋กํ•˜๊ณ , ๋‚˜์™€ ๊ธฐ์ˆ  ๊ถํ•ฉ์ด ์ž˜ ๋งž๋Š” ๊ธฐ์—…๋“ค์„ ๋งค์นญ ๋ฐ›์œผ์„ธ์š”.

programmers.co.kr

 

๐Ÿ’ก ์•„์ด๋””์–ด

1. ๋ฌธ์ž์—ด s ๋ฅผ ๋ฆฌ์ŠคํŠธ์— int๋กœ ๋ณ€ํ™˜ํ•˜๊ธฐ

2. ์ตœ์†Œ/์ตœ๋Œ€๊ฐ’์„ answer_list์— ๋‹ด๊ธฐ

3. answer_list๋ฅผ ๋ฌธ์ž์—ด๋กœ join ํ•ด์ฃผ๊ธฐ!

 

โœ๏ธ๋‚ดํ’€์ด

def solution(s):
	# ๋ฌธ์ž์—ด s๋ฅผ int๋กœ ๋ณ€ํ™˜ํ•˜์—ฌ ๋‹ด๊ธฐ
    s_list = list(map(int, s.split()))
    
    # ์ตœ๋Œ€, ์ตœ์†Œ๊ฐ’ ๋‹ด์„ ๋ฆฌ์ŠคํŠธ
    answer_list = []
    answer_list.append(min(s_list))
    answer_list.append(max(s_list))
    
    # ๋งˆ์ง€๋ง‰์œผ๋กœ joinํ•ด์„œ ๋ฌธ์ž์—ด ์ถœ๋ ฅ
    answer = " ".join(map(str, answer_list))
    return answer

 

๐Ÿ˜Šํ›„๊ธฐ

์‚ฌ์‹ค ์˜ค๋Š˜ ๋ฌธ์ œ๊ฐ€ ๋„ˆ๋ฌด ์‰ฌ์›Œ์„œ ์‹œ๊ฐ„ ์ œํ•œ ์กฐ๊ฑด์ด ์žˆ๋‚˜? ์‹ถ์—ˆ๋Š”๋ฐ ๋ฌธ์ œ, ์กฐ๊ฑด ๋“ฑ๋“ฑ ์•„๋ฌด๊ณณ์—๋„ ๊ทธ๋Ÿฐ ์ œ์•ฝ์ด ์—†์–ด์„œ ๋‹นํ™ฉํ–ˆ๋‹ค.

์˜ค๋Š˜ ์ƒ๋‹ด์ด ์žˆ์–ด์„œ ์•Œ๊ณ ๋ฆฌ์ฆ˜ ํ’€ ์‹œ๊ฐ„์ด ๋น ๋“ฏํ–ˆ๋Š”๋ฐ ๋‹คํ–‰์ด ์‹œ๊ฐ„๋‚ด์— ํ’€ ์ˆ˜ ์žˆ์–ด์„œ ๋‹คํ–‰์ด์—ˆ๋‹ค.

 

+ ์ œ์ถœํ•˜๊ณ ,, ํ•œ ๋ฌธ์ œ ๋” ํ’€์–ด๋ด์•ผ์ง€ ~