Coding 63

210127_Code in the morning (๋‹ค๋ฆฌ๋ฅผ ์ง€๋‚˜๋Š” ํŠธ๋Ÿญ) ๋‹ค์‹œ ํ’€ ๊ฒƒ

๐Ÿ’ฌ ๋ฌธ์ œ ์„ค๋ช… ํŠธ๋Ÿญ ์—ฌ๋Ÿฌ ๋Œ€๊ฐ€ ๊ฐ•์„ ๊ฐ€๋กœ์ง€๋ฅด๋Š” ์ผ์ฐจ์„  ๋‹ค๋ฆฌ๋ฅผ ์ •ํ•ด์ง„ ์ˆœ์œผ๋กœ ๊ฑด๋„ˆ๋ ค ํ•ฉ๋‹ˆ๋‹ค. ๋ชจ๋“  ํŠธ๋Ÿญ์ด ๋‹ค๋ฆฌ๋ฅผ ๊ฑด๋„ˆ๋ ค๋ฉด ์ตœ์†Œ ๋ช‡ ์ดˆ๊ฐ€ ๊ฑธ๋ฆฌ๋Š”์ง€ ์•Œ์•„๋‚ด์•ผ ํ•ฉ๋‹ˆ๋‹ค. ๋‹ค๋ฆฌ์—๋Š” ํŠธ๋Ÿญ์ด ์ตœ๋Œ€ bridge_length๋Œ€ ์˜ฌ๋ผ๊ฐˆ ์ˆ˜ ์žˆ์œผ๋ฉฐ, ๋‹ค๋ฆฌ๋Š” weight ์ดํ•˜๊นŒ์ง€์˜ ๋ฌด๊ฒŒ๋ฅผ ๊ฒฌ๋”œ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ๋‹จ, ๋‹ค๋ฆฌ์— ์™„์ „ํžˆ ์˜ค๋ฅด์ง€ ์•Š์€ ํŠธ๋Ÿญ์˜ ๋ฌด๊ฒŒ๋Š” ๋ฌด์‹œํ•ฉ๋‹ˆ๋‹ค. ์˜ˆ๋ฅผ ๋“ค์–ด, ํŠธ๋Ÿญ 2๋Œ€๊ฐ€ ์˜ฌ๋ผ๊ฐˆ ์ˆ˜ ์žˆ๊ณ  ๋ฌด๊ฒŒ๋ฅผ 10kg๊นŒ์ง€ ๊ฒฌ๋””๋Š” ๋‹ค๋ฆฌ๊ฐ€ ์žˆ์Šต๋‹ˆ๋‹ค. ๋ฌด๊ฒŒ๊ฐ€ [7, 4, 5, 6]kg์ธ ํŠธ๋Ÿญ์ด ์ˆœ์„œ๋Œ€๋กœ ์ตœ๋‹จ ์‹œ๊ฐ„ ์•ˆ์— ๋‹ค๋ฆฌ๋ฅผ ๊ฑด๋„ˆ๋ ค๋ฉด ๋‹ค์Œ๊ณผ ๊ฐ™์ด ๊ฑด๋„ˆ์•ผ ํ•ฉ๋‹ˆ๋‹ค. solution ํ•จ์ˆ˜์˜ ๋งค๊ฐœ๋ณ€์ˆ˜๋กœ ๋‹ค๋ฆฌ์— ์˜ฌ๋ผ๊ฐˆ ์ˆ˜ ์žˆ๋Š” ํŠธ๋Ÿญ ์ˆ˜ bridge_length, ๋‹ค๋ฆฌ๊ฐ€ ๊ฒฌ๋”œ ์ˆ˜ ์žˆ๋Š” ๋ฌด๊ฒŒ weight, ํŠธ๋Ÿญ ๋ณ„ ๋ฌด๊ฒŒ truck_weigh..

220118_Code in the morning (๊ธฐ๋Šฅ๊ฐœ๋ฐœ)

๐Ÿ’ฌ ๋ฌธ์ œ ์„ค๋ช…: ๊ธฐ๋Šฅ๊ฐœ๋ฐœ ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค ํŒ€์—์„œ๋Š” ๊ธฐ๋Šฅ ๊ฐœ์„  ์ž‘์—…์„ ์ˆ˜ํ–‰ ์ค‘์ž…๋‹ˆ๋‹ค. ๊ฐ ๊ธฐ๋Šฅ์€ ์ง„๋„๊ฐ€ 100%์ผ ๋•Œ ์„œ๋น„์Šค์— ๋ฐ˜์˜ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ๋˜, ๊ฐ ๊ธฐ๋Šฅ์˜ ๊ฐœ๋ฐœ์†๋„๋Š” ๋ชจ๋‘ ๋‹ค๋ฅด๊ธฐ ๋•Œ๋ฌธ์— ๋’ค์— ์žˆ๋Š” ๊ธฐ๋Šฅ์ด ์•ž์— ์žˆ๋Š” ๊ธฐ๋Šฅ๋ณด๋‹ค ๋จผ์ € ๊ฐœ๋ฐœ๋  ์ˆ˜ ์žˆ๊ณ , ์ด๋•Œ ๋’ค์— ์žˆ๋Š” ๊ธฐ๋Šฅ์€ ์•ž์— ์žˆ๋Š” ๊ธฐ๋Šฅ์ด ๋ฐฐํฌ๋  ๋•Œ ํ•จ๊ป˜ ๋ฐฐํฌ๋ฉ๋‹ˆ๋‹ค. ๋จผ์ € ๋ฐฐํฌ๋˜์–ด์•ผ ํ•˜๋Š” ์ˆœ์„œ๋Œ€๋กœ ์ž‘์—…์˜ ์ง„๋„๊ฐ€ ์ ํžŒ ์ •์ˆ˜ ๋ฐฐ์—ด progresses์™€ ๊ฐ ์ž‘์—…์˜ ๊ฐœ๋ฐœ ์†๋„๊ฐ€ ์ ํžŒ ์ •์ˆ˜ ๋ฐฐ์—ด speeds๊ฐ€ ์ฃผ์–ด์งˆ ๋•Œ ๊ฐ ๋ฐฐํฌ๋งˆ๋‹ค ๋ช‡ ๊ฐœ์˜ ๊ธฐ๋Šฅ์ด ๋ฐฐํฌ๋˜๋Š”์ง€๋ฅผ return ํ•˜๋„๋ก solution ํ•จ์ˆ˜๋ฅผ ์™„์„ฑํ•˜์„ธ์š”. ๐Ÿ“ ์ œํ•œ ์‚ฌํ•ญ ์ž‘์—…์˜ ๊ฐœ์ˆ˜(progresses, speeds๋ฐฐ์—ด์˜ ๊ธธ์ด)๋Š” 100๊ฐœ ์ดํ•˜์ž…๋‹ˆ๋‹ค. ์ž‘์—… ์ง„๋„๋Š” 100 ๋ฏธ๋งŒ์˜ ์ž์—ฐ์ˆ˜์ž…๋‹ˆ๋‹ค. ์ž‘์—… ์†๋„๋Š”..

[Python]2021 ๋„ทํ”Œ๋ฆญ์Šค์— ์‹œ๊ฐ„์„ ์–ผ๋งˆ๋‚˜ ์Ÿ์•˜๋‹ˆ? (๋ถ€์ œ: ๋„ทํ”Œ๋ฆญ์Šค ๊ฐœ์ธ ์‹œ์ฒญ ๋ฐ์ดํ„ฐ ๋ถ„์„)

๋„ทํ”Œ๋ฆญ์Šค ๊ตฌ๋…ํ•œ์ง€ ์–ด์–ธ 2๋…„์ฐจ ๋„ทํ”Œ์€ ๊ณต๊ธฐ์™€ ๊ฐ™์€ ์กด์žฌ.. ๊ทธ๋Ÿฌ๋‚˜ ๋ฌธ๋“ ๋“œ๋Š” ์ƒ๊ฐ์ด ์žˆ์—ˆ๋‹ค. โ“ ๋‚˜๋Š” ๋„ทํ”Œ๋ฆญ์Šค ๋ณด๋Š”๋ฐ ์–ผ๋งˆ๋‚˜ ์‹œ๊ฐ„์„ ์“ฐ๊ณ ์žˆ๋‚˜? MBTI power J์ธ ๋‚˜๋Š” ์ด ๊ฒƒ์ด ๊ถ๊ธˆํ•ด์กŒ๊ณ , โ“ ๋‚˜๋Š” ์ด ๋ช‡ํŽธ์˜ ์‹œ๋ฆฌ์ฆˆ๋ฅผ ๋ดค์„๊นŒ? โ“ 2021๋…„ ๊ฐ€์žฅ ๋งŽ์€ ์‹œ๊ฐ„์„ ํ• ์• ํ•œ ๋„ทํ”Œ ์ฝ˜ํ…์ธ ๋Š”? โ“ ๋ฌด์Šจ ์š”์ผ์— ๊ฐ€์žฅ ๋งŽ์ด ๋ดค์„๊นŒ? โ“ ์ฃผ๋กœ ๋ณด๋Š” ์‹œ๊ฐ„๋Œ€๋Š” ์–ธ์ œ์ธ๊ฐ€? . . . ๋“ฑ๋“ฑ๋“ฑ ๋“œ๋Š” ๊ถ๊ธˆ์ฆ์„ ํ•ด๊ฒฐํ•ด๋ณด๊ณ ์ž ์‹œ์ž‘ํ•ด๋ณธ ๋‚˜์˜ ๋„ทํ”Œ๋ฆญ์Šค ๋ฐ์ดํ„ฐ ๋ถ„์„ START! Step 1. ๋„ทํ”Œ๋ฆญ์Šค ๋ฐ์ดํ„ฐ ๋‹ค์šด๋กœ๋“œ ๋ฐ›๊ธฐ ๋Œ€๋ถ€๋ถ„์˜ ์‚ฌ๋žŒ๋“ค์ด ์•„์ง ์ž˜ ๋ชจ๋ฅด๊ณ  ์žˆ์„ ๊ฟ€์ •๋ณด. ๋„ทํ”Œ๋ฆญ์Šค๋Š” ๊ตฌ๋…์ž์˜ ๋ฐ์ดํ„ฐ๋ฅผ ์•„์ฃผ ๊ด€๋Œ€ํ•˜๊ฒŒ ์ œ๊ณตํ•ด์ค€๋‹ค. ์—ฌ๊ธฐ์— ์ ‘์†ํ•ด์„œ ๋„ทํ”Œ๋ฆญ์Šค ์ •๋ณด๋ฅผ ์š”์ฒญํ•˜๋ฉด ์ˆ˜ ์ผ ๋‚ด์— ๋‹ค์šด์„ ๋ฐ›์„ ์ˆ˜ ์žˆ๋‹ค๋Š” ์‚ฌ์‹ค. ๋นจ๊ฐ„ ๋ฒ„ํŠผ์˜ ์š”์ฒญํ•˜๊ธฐ ํด๋ฆญํ•˜๋ฉด..

Coding/Python 2022.01.18

220117_Code in the morning (์ฃผ์‹๊ฐ€๊ฒฉ)

๐Ÿ’ฌ ๋ฌธ์ œ ์„ค๋ช…: ์ฃผ์‹๊ฐ€๊ฒฉ ์ดˆ ๋‹จ์œ„๋กœ ๊ธฐ๋ก๋œ ์ฃผ์‹๊ฐ€๊ฒฉ์ด ๋‹ด๊ธด ๋ฐฐ์—ด prices๊ฐ€ ๋งค๊ฐœ๋ณ€์ˆ˜๋กœ ์ฃผ์–ด์งˆ ๋•Œ, ๊ฐ€๊ฒฉ์ด ๋–จ์–ด์ง€์ง€ ์•Š์€ ๊ธฐ๊ฐ„์€ ๋ช‡ ์ดˆ์ธ์ง€๋ฅผ return ํ•˜๋„๋ก solution ํ•จ์ˆ˜๋ฅผ ์™„์„ฑํ•˜์„ธ์š”. ๐Ÿ“ ์ œํ•œ ์‚ฌํ•ญ prices์˜ ๊ฐ ๊ฐ€๊ฒฉ์€ 1 ์ด์ƒ 10,000 ์ดํ•˜์ธ ์ž์—ฐ์ˆ˜์ž…๋‹ˆ๋‹ค. prices์˜ ๊ธธ์ด๋Š” 2 ์ด์ƒ 100,000 ์ดํ•˜์ž…๋‹ˆ๋‹ค. ์ž…์ถœ๋ ฅ ์˜ˆ ์„ค๋ช… 1์ดˆ ์‹œ์ ์˜ โ‚ฉ1์€ ๋๊นŒ์ง€ ๊ฐ€๊ฒฉ์ด ๋–จ์–ด์ง€์ง€ ์•Š์•˜์Šต๋‹ˆ๋‹ค. 2์ดˆ ์‹œ์ ์˜ โ‚ฉ2์€ ๋๊นŒ์ง€ ๊ฐ€๊ฒฉ์ด ๋–จ์–ด์ง€์ง€ ์•Š์•˜์Šต๋‹ˆ๋‹ค. 3์ดˆ ์‹œ์ ์˜ โ‚ฉ3์€ 1์ดˆ๋’ค์— ๊ฐ€๊ฒฉ์ด ๋–จ์–ด์ง‘๋‹ˆ๋‹ค. ๋”ฐ๋ผ์„œ 1์ดˆ๊ฐ„ ๊ฐ€๊ฒฉ์ด ๋–จ์–ด์ง€์ง€ ์•Š์€ ๊ฒƒ์œผ๋กœ ๋ด…๋‹ˆ๋‹ค. 4์ดˆ ์‹œ์ ์˜ โ‚ฉ2์€ 1์ดˆ๊ฐ„ ๊ฐ€๊ฒฉ์ด ๋–จ์–ด์ง€์ง€ ์•Š์•˜์Šต๋‹ˆ๋‹ค. 5์ดˆ ์‹œ์ ์˜ โ‚ฉ3์€ 0์ดˆ๊ฐ„ ๊ฐ€๊ฒฉ์ด ๋–จ์–ด์ง€์ง€ ์•Š์•˜์Šต๋‹ˆ๋‹ค. ๐Ÿ’ก ๋‚˜์˜ ํ’€์ด def solution..

220110_Code in the morning

๐Ÿ’ฌ ๋ฌธ์ œ ์„ค๋ช…: ์‹œ์ € ์•”ํ˜ธ ์–ด๋–ค ๋ฌธ์žฅ์˜ ๊ฐ ์•ŒํŒŒ๋ฒณ์„ ์ผ์ •ํ•œ ๊ฑฐ๋ฆฌ๋งŒํผ ๋ฐ€์–ด์„œ ๋‹ค๋ฅธ ์•ŒํŒŒ๋ฒณ์œผ๋กœ ๋ฐ”๊พธ๋Š” ์•”ํ˜ธํ™” ๋ฐฉ์‹์„ ์‹œ์ € ์•”ํ˜ธ๋ผ๊ณ  ํ•ฉ๋‹ˆ๋‹ค. ์˜ˆ๋ฅผ ๋“ค์–ด "AB"๋Š” 1๋งŒํผ ๋ฐ€๋ฉด "BC"๊ฐ€ ๋˜๊ณ , 3๋งŒํผ ๋ฐ€๋ฉด "DE"๊ฐ€ ๋ฉ๋‹ˆ๋‹ค. "z"๋Š” 1๋งŒํผ ๋ฐ€๋ฉด "a"๊ฐ€ ๋ฉ๋‹ˆ๋‹ค. ๋ฌธ์ž์—ด s์™€ ๊ฑฐ๋ฆฌ n์„ ์ž…๋ ฅ๋ฐ›์•„ s๋ฅผ n๋งŒํผ ๋ฏผ ์•”ํ˜ธ๋ฌธ์„ ๋งŒ๋“œ๋Š” ํ•จ์ˆ˜, solution์„ ์™„์„ฑํ•ด ๋ณด์„ธ์š”. ๐Ÿ“ ์ œํ•œ ์‚ฌํ•ญ ๊ณต๋ฐฑ์€ ์•„๋ฌด๋ฆฌ ๋ฐ€์–ด๋„ ๊ณต๋ฐฑ์ž…๋‹ˆ๋‹ค. s๋Š” ์•ŒํŒŒ๋ฒณ ์†Œ๋ฌธ์ž, ๋Œ€๋ฌธ์ž, ๊ณต๋ฐฑ์œผ๋กœ๋งŒ ์ด๋ฃจ์–ด์ ธ ์žˆ์Šต๋‹ˆ๋‹ค. s์˜ ๊ธธ์ด๋Š” 8000์ดํ•˜์ž…๋‹ˆ๋‹ค. n์€ 1 ์ด์ƒ, 25์ดํ•˜์ธ ์ž์—ฐ์ˆ˜์ž…๋‹ˆ๋‹ค. ๐Ÿ’ก ๋‚˜์˜ ํ’€์ด def solution(s, n): s = list(s) for i in range(len(s)): if s[i].isupper(): s[i]=chr(..

220105_Code in the morning

๐Ÿ’ฌ ๋ฌธ์ œ ์„ค๋ช…: ์˜ˆ์‚ฐ S์‚ฌ์—์„œ๋Š” ๊ฐ ๋ถ€์„œ์— ํ•„์š”ํ•œ ๋ฌผํ’ˆ์„ ์ง€์›ํ•ด ์ฃผ๊ธฐ ์œ„ํ•ด ๋ถ€์„œ๋ณ„๋กœ ๋ฌผํ’ˆ์„ ๊ตฌ๋งคํ•˜๋Š”๋ฐ ํ•„์š”ํ•œ ๊ธˆ์•ก์„ ์กฐ์‚ฌํ–ˆ์Šต๋‹ˆ๋‹ค. ๊ทธ๋Ÿฌ๋‚˜, ์ „์ฒด ์˜ˆ์‚ฐ์ด ์ •ํ•ด์ ธ ์žˆ๊ธฐ ๋•Œ๋ฌธ์— ๋ชจ๋“  ๋ถ€์„œ์˜ ๋ฌผํ’ˆ์„ ๊ตฌ๋งคํ•ด ์ค„ ์ˆ˜๋Š” ์—†์Šต๋‹ˆ๋‹ค. ๊ทธ๋ž˜์„œ ์ตœ๋Œ€ํ•œ ๋งŽ์€ ๋ถ€์„œ์˜ ๋ฌผํ’ˆ์„ ๊ตฌ๋งคํ•ด ์ค„ ์ˆ˜ ์žˆ๋„๋ก ํ•˜๋ ค๊ณ  ํ•ฉ๋‹ˆ๋‹ค. ๋ฌผํ’ˆ์„ ๊ตฌ๋งคํ•ด ์ค„ ๋•Œ๋Š” ๊ฐ ๋ถ€์„œ๊ฐ€ ์‹ ์ฒญํ•œ ๊ธˆ์•ก๋งŒํผ์„ ๋ชจ๋‘ ์ง€์›ํ•ด ์ค˜์•ผ ํ•ฉ๋‹ˆ๋‹ค. ์˜ˆ๋ฅผ ๋“ค์–ด 1,000์›์„ ์‹ ์ฒญํ•œ ๋ถ€์„œ์—๋Š” ์ •ํ™•ํžˆ 1,000์›์„ ์ง€์›ํ•ด์•ผ ํ•˜๋ฉฐ, 1,000์›๋ณด๋‹ค ์ ์€ ๊ธˆ์•ก์„ ์ง€์›ํ•ด ์ค„ ์ˆ˜๋Š” ์—†์Šต๋‹ˆ๋‹ค. ๋ถ€์„œ๋ณ„๋กœ ์‹ ์ฒญํ•œ ๊ธˆ์•ก์ด ๋“ค์–ด์žˆ๋Š” ๋ฐฐ์—ด d์™€ ์˜ˆ์‚ฐ budget์ด ๋งค๊ฐœ๋ณ€์ˆ˜๋กœ ์ฃผ์–ด์งˆ ๋•Œ, ์ตœ๋Œ€ ๋ช‡ ๊ฐœ์˜ ๋ถ€์„œ์— ๋ฌผํ’ˆ์„ ์ง€์›ํ•  ์ˆ˜ ์žˆ๋Š”์ง€ return ํ•˜๋„๋ก solution ํ•จ์ˆ˜๋ฅผ ์™„์„ฑํ•ด์ฃผ์„ธ์š”. ๐Ÿ“ ์ œํ•œ ์‚ฌํ•ญ d๋Š” ..

[Python] ์—ฐ์Šต๋ฌธ์ œ(๋ฌธ์žฅ ๋งŒ๋“ค๊ธฐ)

1. ๋ฌธ์žฅ ๋งŒ๋“ค๊ธฐ # ๋ฌธ์žฅ์„ ์ž…๋ ฅ๋ฐ›์•„์„œ ๋ฌธ๋ฒ•์— ๋งž๋„๋ก ๊ฒฐ๊ณผ๋ฅผ ์ถœ๋ ฅํ•˜๋Š” ์ฝ”๋“œ๋ฅผ ์ž‘์„ฑ # ๋งˆ์ง€๋ง‰ ๋ฌธ์ž๋Š” . ์ด ์žˆ์„์ˆ˜๋„ ์žˆ๊ณ  ์—†์„์ˆ˜๋„ ์žˆ์Šต๋‹ˆ๋‹ค. # ๋…ผ๋ฆฌ์ ์ธ ๋ฌธ์ œํ•ด๊ฒฐ ์ˆœ์„œ -> ์ฝ”๋“œ๋กœ ๋ณ€๊ฒฝ # str.upper(), str.lower(),, offset index [], str.__add__(๋ฌธ์ž์—ด ๋ง์…ˆ) # python IS the best Language / python IS the best Language. # Python is the best language. #๊ฐ’์„ ์ž…๋ ฅ๋ฐ›๊ธฐ sentence = input("input: ") #2. ๋ชจ๋‘ ์†Œ๋ฌธ์ž๋กœ ๋ณ€๊ฒฝ result = sentence.lower() #3. ๊ฐ€์žฅ ์•ž๊ธ€์ž ๋Œ€๋ฌธ์ž๋กœ ๋ณ€๊ฒฝ result = result[0].upper() + result[1:]..

Coding/Python 2021.12.30

[Python] *args, **kwargs

*args, **kwargs ํ•จ์ˆ˜๋ฅผ ํ˜ธ์ถœํ• ๋•Œ ์•„๊ทœ๋จผํŠธ์™€ ํ‚ค์›Œ๋“œ ์•„๊ทœ๋จผํŠธ์˜ ๊ฐฏ์ˆ˜๋ฅผ ํŠน์ •์ง€์„ ์ˆ˜ ์—†์„๋•Œ ์‚ฌ์šฉ ํ‚ค์›Œ๋“œ๊ฐ€ ์—†๋Š” Argument def plus(*args, **kwargs): print(type(args), args) print(type(kwargs), kwargs) return sum(args) + sum(list(kwargs.values())) (1, 2, 3, 4, 5) {'num1': 6, 'num2': 7} ํ‚ค์›Œ๋“œ๊ฐ€ ์žˆ๋Š” Argument : kwargs๋ฅผ ์‚ฌ์šฉํ•จ ์˜ˆ์‹œ : def func(num1, num2, num3): retrun num1 + num2 + num3 data = [1,2,3] func(*data) #func(1, 2, 3) ํ•˜๋‚˜ํ•˜๋‚˜ ์ธ์ž ํ•˜๋‚˜์”ฉ ์ˆœ์ฐจ์ ์œผ๋กœ ํ•จ์ˆ˜๋ฅผ ํ˜ธ์ถœํ•˜๊ฒŒ..

Coding/Python 2021.12.30

211230_Code in the morning(์†Œ์ˆ˜์ฐพ๊ธฐ, ์—๋ผํ† ์Šคํ…Œ๋„ค์Šค์˜ ์ฒด)

๐Ÿ’ฌ ๋ฌธ์ œ ์„ค๋ช…: ์†Œ์ˆ˜ ์ฐพ๊ธฐ 1๋ถ€ํ„ฐ ์ž…๋ ฅ๋ฐ›์€ ์ˆซ์ž n ์‚ฌ์ด์— ์žˆ๋Š” ์†Œ์ˆ˜์˜ ๊ฐœ์ˆ˜๋ฅผ ๋ฐ˜ํ™˜ํ•˜๋Š” ํ•จ์ˆ˜, solution์„ ๋งŒ๋“ค์–ด ๋ณด์„ธ์š”. ์†Œ์ˆ˜๋Š” 1๊ณผ ์ž๊ธฐ ์ž์‹ ์œผ๋กœ๋งŒ ๋‚˜๋ˆ„์–ด์ง€๋Š” ์ˆ˜๋ฅผ ์˜๋ฏธํ•ฉ๋‹ˆ๋‹ค. (1์€ ์†Œ์ˆ˜๊ฐ€ ์•„๋‹™๋‹ˆ๋‹ค.) ๐Ÿ“ ์ œํ•œ ์‚ฌํ•ญ n์€ 2์ด์ƒ 1000000์ดํ•˜์˜ ์ž์—ฐ์ˆ˜์ž…๋‹ˆ๋‹ค. ๐Ÿ’ก ๋‚˜์˜ ํ’€์ด from collections import Counter def solution(n): num = [] # ์†Œ์ˆ˜๋ฅผ ์ฐพ๋Š” ์‹ for i in range (1,n+1): for j in range (1, n+1): if i % j == 0: num.append(i) cnt = Counter(num) a = [] for i in range (1, n+1): if (cnt[i] == 2): a.append(i) return(le..

[python] list Comprehension, ์‚ผํ•ญ ์—ฐ์‚ฐ์ž

List Comprehension List comprehension offers a shorter syntax when you want to create a new list based on the values of an existing list. ์˜ˆ๋ฅผ ๋“ค์–ด๋ณด์ž. Without list comprehension you will have to write a for statement with a conditional test inside: Example fruits = ["apple", "banana", "cherry", "kiwi", "mango"] newlist = [] for x in fruits: if "a" in x: newlist.append(x) print(newlist) With list com..

Coding/Python 2021.12.29