๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ

๐Ÿ Python

(21)
๋ฐฑ์ค€ 1755 [์ˆซ์ž๋†€์ด] : ํŒŒ์ด์ฌ & ๋ฌธ์ž์—ด ์ •๋ ฌ (with maketrans & translate, join) ๐Ÿ“Œ ๋ฌธ์ œ https://www.acmicpc.net/problem/1755 1755๋ฒˆ: ์ˆซ์ž๋†€์ด 79๋ฅผ ์˜์–ด๋กœ ์ฝ๋˜ ์ˆซ์ž ๋‹จ์œ„๋กœ ํ•˜๋‚˜์”ฉ ์ฝ๋Š”๋‹ค๋ฉด "seven nine"์ด ๋œ๋‹ค. 80์€ ๋งˆ์ฐฌ๊ฐ€์ง€๋กœ "eight zero"๋ผ๊ณ  ์ฝ๋Š”๋‹ค. 79๋Š” 80๋ณด๋‹ค ์ž‘์ง€๋งŒ, ์˜์–ด๋กœ ์ˆซ์ž ํ•˜๋‚˜์”ฉ ์ฝ๋Š”๋‹ค๋ฉด "eight zero"๊ฐ€ "seven nine"๋ณด๋‹ค ์‚ฌ์ „์ˆœ์œผ๋กœ www.acmicpc.net ๐Ÿ” ํ’€์ด 1. ์ฒซ๋ฒˆ์งธ ์‹œ๋„ ์ผ๋‹จ ํ’€์–ด๋ณธ ๋ฐฉ๋ฒ• ! [์ „์ฒด ์ฝ”๋“œ] '''์ตœ์ข… ์ œ์ถœ ์ฝ”๋“œ''' M , N = map(int, input().split()) num_list = [str(i) for i in range(M, N + 1)] def convert_to_str(txt): dictionary = {'0':'zero', '1':'one..
[python] lambda ๋žŒ๋‹ค ํ•จ์ˆ˜ & filter & map & List Comprehension example codeโœŠ๐Ÿป Hello๐Ÿ‘‹ I'm Dona!:) ์ง€๋‚œ list sorting(2) ํฌ์ŠคํŒ…์—์„œ ๋žŒ๋‹ค ํ•จ์ˆ˜๋ฅผ ์‚ฌ์šฉํ–ˆ๋Š”๋ฐ, ๋Œ“๊ธ€๋กœ ์งˆ๋ฌธ์ด ์žˆ์–ด์„œ ์ค€๋น„ํ–ˆ์Šต๋‹ˆ๋‹ค! ์ €๋„ ์ฒ˜์Œ ๋žŒ๋‹ค ํ•จ์ˆ˜๋ฅผ ๋ดค์„ ๋•Œ๋Š”, ์–ด๋ ค์›Œ ๋ณด์—ฌ์„œ ๋‘๋ ค์› ๋Š”๋ฐ ๋ง‰์ƒ ์‚ฌ์šฉํ•ด ๋ณด๋‹ˆ ๋ณ„๊ฑฐ์•„๋‹™๋‹ˆ๋‹ค! ์—„์ฒญ ํŽธ๋ฆฌํ•œ ๋…€์„์ด๋‹ˆ ๊ผญ ๋‚ด ๊ฒƒ์œผ๋กœ ๋งŒ๋“ค์–ด ๊ฐ‘์‹œ๋‹ค! โœŠ๐Ÿป๐Ÿ”ฅ - ์ง€๋‚œ ํฌ์ŠคํŒ… : https://imdona.tistory.com/14 [python] List(2) list sorting : ๋‹ค์ค‘ ์กฐ๊ฑด ์ •๋ ฌ & ๋ฐฑ์ค€ 1181๋ฒˆ[๋‹จ์–ด ์ •๋ ฌ] Hello๐Ÿ‘‹ I'm Dona!:) ์ง€๋‚œ ํฌ์ŠคํŒ…์— ์ด์–ด์„œ ์•Œ๊ณ ๋ฆฌ์ฆ˜ ๋ฌธ์ œ์—์„œ ์ž์ฃผ ์“ฐ์ด๋Š” ๋‹ค์ค‘ ์กฐ๊ฑด ์ •๋ ฌ์— ๋Œ€ํ•ด ์•Œ์•„๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค. sort์™€ sorted์˜ documentation ์†Œ๊ฐœ๋Š” ์ง€๋‚œ ํฌ์ŠคํŒ… ์ฐธ๊ณ ํ•ด์ฃผ์„ธ์š”! โฌ‡๏ธโฌ‡๏ธโฌ‡๏ธโฌ‡๏ธโฌ‡ imdona.t..
[python] List(2) list sorting : ๋‹ค์ค‘ ์กฐ๊ฑด ์ •๋ ฌ & ๋ฐฑ์ค€ 1181๋ฒˆ[๋‹จ์–ด ์ •๋ ฌ] Hello๐Ÿ‘‹ I'm Dona!:) ์ง€๋‚œ ํฌ์ŠคํŒ…์— ์ด์–ด์„œ ์•Œ๊ณ ๋ฆฌ์ฆ˜ ๋ฌธ์ œ์—์„œ ์ž์ฃผ ์“ฐ์ด๋Š” ๋‹ค์ค‘ ์กฐ๊ฑด ์ •๋ ฌ์— ๋Œ€ํ•ด ์•Œ์•„๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค. sort์™€ sorted์˜ documentation ์†Œ๊ฐœ๋Š” ์ง€๋‚œ ํฌ์ŠคํŒ… ์ฐธ๊ณ ํ•ด์ฃผ์„ธ์š”! โฌ‡๏ธโฌ‡๏ธโฌ‡๏ธโฌ‡๏ธโฌ‡๏ธ https://imdona.tistory.com/12 [python] List(1) list sorting : sort & sorted ์†Œ๊ฐœ Hello, I'm Dona!:) ์•„์ง ๋ถ€์กฑํ•˜์ง€๋งŒ, ์–ด๋Š๋ง ํŒŒ์ด์ฌ ๊ณต๋ถ€๋ฅผ ์‹œ์ž‘ํ•œ ์ง€ ๋ฐ˜๋…„์ด ๋‹ค ๋˜์–ด๊ฐ‘๋‹ˆ๋‹ค. ๋ ˆ๋ฒจ์ด ์˜ฌ๋ผ๊ฐˆ์ˆ˜๋ก ๊ธฐ์ดˆ์ ์ธ ๋ถ€๋ถ„์—์„œ ๊ฐ€์žฅ ์ค‘์š”ํ•œ ๊ฒƒ์ด ๋‚˜์˜จ๋‹ค๋Š” ๊ฒƒ์„ ๋Š๋ผ๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค. ํŒŒ์ด์ฌ์„ ์ฒ˜ imdona.tistory.com ๋ฐฑ์ค€ ์•Œ๊ณ ๋ฆฌ์ฆ˜ ๋ฌธ์ œ๋ฅผ ์˜ˆ์‹œ๋กœ ๋ฐฐ์›Œ๋ด…์‹œ๋‹ค! ๋ฐฑ์ค€ 1181๋ฒˆ [๋‹จ์–ด ์ •๋ ฌ] ๋ฌธ์ œ ์•ŒํŒŒ๋ฒณ ์†Œ๋ฌธ์ž๋กœ ์ด๋ฃจ์–ด์ง„ ..
[python] List(1) list sorting : sort & sorted ์†Œ๊ฐœ Hello, I'm Dona!:) ์•„์ง ๋ถ€์กฑํ•˜์ง€๋งŒ, ์–ด๋Š๋ง ํŒŒ์ด์ฌ ๊ณต๋ถ€๋ฅผ ์‹œ์ž‘ํ•œ ์ง€ ๋ฐ˜๋…„์ด ๋‹ค ๋˜์–ด๊ฐ‘๋‹ˆ๋‹ค. ๋ ˆ๋ฒจ์ด ์˜ฌ๋ผ๊ฐˆ์ˆ˜๋ก ๊ธฐ์ดˆ์ ์ธ ๋ถ€๋ถ„์—์„œ ๊ฐ€์žฅ ์ค‘์š”ํ•œ ๊ฒƒ์ด ๋‚˜์˜จ๋‹ค๋Š” ๊ฒƒ์„ ๋Š๋ผ๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค. ํŒŒ์ด์ฌ์„ ์ฒ˜์Œ ๋ฐฐ์› ์„ ๋•Œ ์ดˆ์‹ฌ์„ ์ƒ๊ฐํ•˜๋ฉฐ, ์ €๋งŒ์˜ basic series๋ฅผ ์‹œ์ž‘ํ•˜๋ ค๊ณ  ํ•ฉ๋‹ˆ๋‹ค! ์ˆœ์„œ๋Š” ๋’ค์ฃฝ๋ฐ•์ฃฝ ์ผ ์ˆ˜๋„ ์žˆ์ง€๋งŒ, ์ตœ๋Œ€ํ•œ sortingํ•ด์„œ ์—ฐ์žฌํ•˜๋ ค๊ณ  ํ•ฉ๋‹ˆ๋‹ค.โ˜บ๏ธ ๋ธ”๋กœ๊น…์„ ํ•˜๋ฉด์„œ ์ € ์Šค์Šค๋กœ๋„ ๋งŽ์ด ์ •๋ฆฌ๊ฐ€ ๋˜๊ณ , ๋‚จ๋“ค์—๊ฒŒ ๋„์›€์ด ๋  ์ˆ˜ ์žˆ๋‹ค๋Š” ์‚ฌ์‹ค์€ ์ €๋ฅผ ํ–‰๋ณตํ•˜๊ฒŒ ํ•˜๋Š” ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค. ๐ŸŒˆ๐Ÿฆ„ ์„œ๋ก ์ด ๊ธธ์—ˆ์Šต๋‹ˆ๋‹ค. ์˜ค๋Š˜์€ list ๋ฉ”์†Œ๋“œ์ธ sort์™€ sorted์— ๋Œ€ํ•ด ์ •๋ฆฌํ•ด ๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค! list.sort( ) sort(*, key=None, reverse=False) 1. ๊ธฐ์กด ๋ฆฌ์ŠคํŠธ๋ฅผ ์ •๋ ฌํ•˜๊ณ , retur..
Python Comprehension ํ™œ์šฉ : ๋ฐฑ์ค€ 1330 [๋‘ ์ˆ˜ ๋น„๊ตํ•˜๊ธฐ] Hello, I'm Dona! ํ•ด๋‹น ๋ฌธ์ œ๋Š” ์‚ฌ์‹ค ์—„์ฒญ ์‰ฌ์šด ๋ฌธ์ œ์ž…๋‹ˆ๋‹ค. ํ•˜์ง€๋งŒ python์—์„œ ์ž์ฃผ ์‚ฌ์šฉํ•˜๋Š” Comprehension์„ ์—ฐ์Šตํ•˜๊ธฐ์— ์•„์ฃผ ์ข‹์€ ๋ฌธ์ œ๋ผ๊ณ  ์ƒ๊ฐํ•ด์„œ ํฌ์ŠคํŒ…ํ•˜๋ ค๊ณ  ํ•ฉ๋‹ˆ๋‹ค :) ๋ฌธ์ œ : ๋‘ ์ •์ˆ˜ A์™€ B๊ฐ€ ์ฃผ์–ด์กŒ์„ ๋•Œ, A์™€ B๋ฅผ ๋น„๊ตํ•˜๋Š” ํ”„๋กœ๊ทธ๋žจ์„ ์ž‘์„ฑํ•˜์‹œ์˜ค. ์ถœ๋ ฅ : ์ฒซ์งธ ์ค„์— ๋‹ค์Œ ์„ธ ๊ฐ€์ง€ ์ค‘ ํ•˜๋‚˜๋ฅผ ์ถœ๋ ฅํ•œ๋‹ค. A๊ฐ€ B๋ณด๋‹ค ํฐ ๊ฒฝ์šฐ์—๋Š” '>'๋ฅผ ์ถœ๋ ฅํ•œ๋‹ค. A๊ฐ€ B๋ณด๋‹ค ์ž‘์€ ๊ฒฝ์šฐ์—๋Š” '') elif a b else '