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

4๏ธโƒฃ Python56

[Python Algorithm] ํ–‰๋ ฌ์˜ ๊ณฑ์…ˆ Programmers(Lv.2) ๋ฌธ์ œ https://programmers.co.kr/learn/courses/30/lessons/12949 ์ฝ”๋”ฉํ…Œ์ŠคํŠธ ์—ฐ์Šต - ํ–‰๋ ฌ์˜ ๊ณฑ์…ˆ [[2, 3, 2], [4, 2, 4], [3, 1, 4]] [[5, 4, 3], [2, 4, 1], [3, 1, 1]] [[22, 22, 11], [36, 28, 18], [29, 20, 14]] programmers.co.kr ๋‚ด ๋ฌธ์ œ ํ’€์ด def solution(arr1, arr2): answer = [[0]*len(arr2[0]) for _ in range(len(arr1))] for i in range(len(arr1)): for j in range(len(arr2[0])): for k in range(len(arr1[0])): answer[i][j] += .. 2022. 2. 4.
[Python Algorithm] ์ตœ๋Œ“๊ฐ’๊ณผ ์ตœ์†Ÿ๊ฐ’ Programmers(Lv.2) ๋ฌธ์ œ 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์„ ๊ตฌํ•ด์ฃผ์—ˆ๋‹ค. ๐Ÿ’ก ํ”ผ๋“œ๋ฐฑ ๋ฌธ์ž์—ด๊ณผ .. 2022. 2. 4.
[Python Algorithm] ์ตœ์†Ÿ๊ฐ’ ๋งŒ๋“ค๊ธฐ Programmers(Lv.2) ๋ฌธ์ œ https://programmers.co.kr/learn/courses/30/lessons/12941?language=python3 ์ฝ”๋”ฉํ…Œ์ŠคํŠธ ์—ฐ์Šต - ์ตœ์†Ÿ๊ฐ’ ๋งŒ๋“ค๊ธฐ ๊ธธ์ด๊ฐ€ ๊ฐ™์€ ๋ฐฐ์—ด A, B ๋‘๊ฐœ๊ฐ€ ์žˆ์Šต๋‹ˆ๋‹ค. ๊ฐ ๋ฐฐ์—ด์€ ์ž์—ฐ์ˆ˜๋กœ ์ด๋ฃจ์–ด์ ธ ์žˆ์Šต๋‹ˆ๋‹ค. ๋ฐฐ์—ด A, B์—์„œ ๊ฐ๊ฐ ํ•œ ๊ฐœ์˜ ์ˆซ์ž๋ฅผ ๋ฝ‘์•„ ๋‘ ์ˆ˜๋ฅผ ๊ณฑํ•ฉ๋‹ˆ๋‹ค. ์ด๋Ÿฌํ•œ ๊ณผ์ •์„ ๋ฐฐ์—ด์˜ ๊ธธ์ด๋งŒํผ ๋ฐ˜๋ณตํ•˜๋ฉฐ, ๋‘ ์ˆ˜๋ฅผ ๊ณฑ programmers.co.kr ๋‚ด ๋ฌธ์ œ ํ’€์ด def solution(A,B): answer = 0 A.sort() B.sort(reverse = True) for i in range(len(A)): answer += (A[i] * B[i]) return answer ๐Ÿ‘‰ ๊ตฌํ˜„ ๋ฌธ์ œ๋กœ, ์ตœ์†Ÿ๊ฐ’์„ ๋งŒ๋“œ๋Š” ๋ฐฉ๋ฒ•๋งŒ ์•Œ๋ฉด ํ’€ ์ˆ˜ ์žˆ๋Š” ๋ฌธ์ œ ํ•œ ๋ฆฌ.. 2022. 2. 4.
[Python Algorithm] ์นดํŽซ Programmers(Lv.2) ๋ฌธ์ œ https://programmers.co.kr/learn/courses/30/lessons/42842 ์ฝ”๋”ฉํ…Œ์ŠคํŠธ ์—ฐ์Šต - ์นดํŽซ Leo๋Š” ์นดํŽซ์„ ์‚ฌ๋Ÿฌ ๊ฐ”๋‹ค๊ฐ€ ์•„๋ž˜ ๊ทธ๋ฆผ๊ณผ ๊ฐ™์ด ์ค‘์•™์—๋Š” ๋…ธ๋ž€์ƒ‰์œผ๋กœ ์น ํ•ด์ ธ ์žˆ๊ณ  ํ…Œ๋‘๋ฆฌ 1์ค„์€ ๊ฐˆ์ƒ‰์œผ๋กœ ์น ํ•ด์ ธ ์žˆ๋Š” ๊ฒฉ์ž ๋ชจ์–‘ ์นดํŽซ์„ ๋ดค์Šต๋‹ˆ๋‹ค. Leo๋Š” ์ง‘์œผ๋กœ ๋Œ์•„์™€์„œ ์•„๊นŒ ๋ณธ ์นดํŽซ์˜ ๋…ธ๋ž€์ƒ‰๊ณผ programmers.co.kr ๋‚ด ๋ฌธ์ œ ํ’€์ด def solution(brown, yellow): answer = [] for i in range(3, brown): if (i - 2) * ((brown - (i * 2)) / 2) == yellow: answer = [(brown - (i * 2)) / 2 + 2, i] break return answer ๐Ÿ‘‰ ์™„์ „ํƒ์ƒ‰ ๋ฌธ์ œ๋กœ, ์นดํŽซ์ด.. 2022. 2. 3.
[Python Algorithm] IOIOI BOJ #5525 ๋ฌธ์ œ https://www.acmicpc.net/problem/5525 5525๋ฒˆ: IOIOI N+1๊ฐœ์˜ I์™€ N๊ฐœ์˜ O๋กœ ์ด๋ฃจ์–ด์ ธ ์žˆ์œผ๋ฉด, I์™€ O์ด ๊ต๋Œ€๋กœ ๋‚˜์˜ค๋Š” ๋ฌธ์ž์—ด์„ PN์ด๋ผ๊ณ  ํ•œ๋‹ค. P1 IOI P2 IOIOI P3 IOIOIOI PN IOIOI...OI (O๊ฐ€ N๊ฐœ) I์™€ O๋กœ๋งŒ ์ด๋ฃจ์–ด์ง„ ๋ฌธ์ž์—ด S์™€ ์ •์ˆ˜ N์ด ์ฃผ์–ด์กŒ์„ ๋•Œ, S์•ˆ์— PN์ด ๋ช‡ www.acmicpc.net ๋‚ด ๋ฌธ์ œ ํ’€์ด import sys n = int(sys.stdin.readline()) m = int(sys.stdin.readline()) s = sys.stdin.readline().strip() idx = 0 count = 0 result = 0 while idx 2022. 2. 3.