๐Ÿ“๋ฌธ์ œ ํ’€์ด

    [SWEA] ํŒŒ์ด์ฌ 1209. Sum

    ~๋ชฉ์ฐจ~ ๋ฌธ์ œ ๋ฌธ์ œ ํ•ด๊ฒฐ ํฌ์ธํŠธ ์ž‘์„ฑ ์ฝ”๋“œ ๋ฌธ์ œ https://swexpertacademy.com/main/code/problem/problemDetail.do?problemLevel=3&contestProbId=AV13_BWKACUCFAYh&categoryId=AV13_BWKACUCFAYh&categoryType=CODE&problemTitle=&orderBy=RECOMMEND_COUNT&selectCodeLang=PYTHON&select-1=3&pageSize=10&pageIndex=1 SW Expert Academy SW ํ”„๋กœ๊ทธ๋ž˜๋ฐ ์—ญ๋Ÿ‰ ๊ฐ•ํ™”์— ๋„์›€์ด ๋˜๋Š” ๋‹ค์–‘ํ•œ ํ•™์Šต ์ปจํ…์ธ ๋ฅผ ํ™•์ธํ•˜์„ธ์š”! swexpertacademy.com ๋ฌธ์ œ ํ•ด๊ฒฐ ํฌ์ธํŠธ - 100ํ–‰์„ ๋ฆฌ์ŠคํŠธ๋กœ ์ฝ์–ด ํ•˜๋‚˜์”ฉ ๋ฐฉ๋ฌธํ•˜๋ฉฐ - ๊ฐ ์ž๋ฆฌ..

    [Python] ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค ๋„คํŠธ์›Œํฌ | BFS/DFS

    ~๋ชฉ์ฐจ~ ๋ฌธ์ œ ๋ฌธ์ œ ํ•ด๊ฒฐ ํฌ์ธํŠธ ์ž‘์„ฑ ์ฝ”๋“œ ๋ฌธ์ œ https://school.programmers.co.kr/learn/courses/30/lessons/43162 ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค ์ฝ”๋“œ ์ค‘์‹ฌ์˜ ๊ฐœ๋ฐœ์ž ์ฑ„์šฉ. ์Šคํƒ ๊ธฐ๋ฐ˜์˜ ํฌ์ง€์…˜ ๋งค์นญ. ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค์˜ ๊ฐœ๋ฐœ์ž ๋งž์ถคํ˜• ํ”„๋กœํ•„์„ ๋“ฑ๋กํ•˜๊ณ , ๋‚˜์™€ ๊ธฐ์ˆ  ๊ถํ•ฉ์ด ์ž˜ ๋งž๋Š” ๊ธฐ์—…๋“ค์„ ๋งค์นญ ๋ฐ›์œผ์„ธ์š”. programmers.co.kr ๋ฌธ์ œ ํ•ด๊ฒฐ ํฌ์ธํŠธ ๋ชจ๋“  ๋…ธ๋“œ๋ฅผ ํƒ์ƒ‰ํ•˜์—ฌ์•ผ ํ•˜๊ธฐ ๋•Œ๋ฌธ์— DFS/BFS ๋‘˜ ๋‹ค ์‚ฌ์šฉํ•˜์—ฌ ๊ตฌํ˜„ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ํ•˜์ง€๋งŒ Python์€ DFS ํšจ์œจ์ด ์ข‹์ง€ ์•Š๊ธฐ ๋•Œ๋ฌธ์— BFS๋ฅผ ์ถ”์ฒœ๋“œ๋ฆฝ๋‹ˆ๋‹ค. BFS - ๋ชจ๋“  ๋…ธ๋“œ๊ฐ€ ์—ฐ๊ฒฐ๋˜์ง€ ์•Š์•˜๊ธฐ ๋•Œ๋ฌธ์— ํ•œ ๋ฒˆ BFS๋ฅผ ๋Œ๊ณ  ๋‚œ ๋’ค ์•„์ง ๋ฐฉ๋ฌธํ•˜์ง€ ์•Š์€ ๋…ธ๋“œ๋ฅผ ๋‹ค์‹œ ์ฐพ์•„์•ผ ํ•จ - ์•„์ง ๋ฐฉ๋ฌธํ•˜์ง€ ์•Š์€ ๋…ธ๋“œ๋ฅผ ๋ฐœ๊ฒฌํ•œ๋‹ค๋ฉด queue..

    [Python] ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค ํƒ€๊ฒŸ ๋„˜๋ฒ„ | DFS/BFS

    ~๋ชฉ์ฐจ~ ๋ฌธ์ œ ๋ฌธ์ œ ํ•ด๊ฒฐ ํฌ์ธํŠธ ์ž‘์„ฑ ์ฝ”๋“œ ๋ฌธ์ œ https://school.programmers.co.kr/learn/courses/30/lessons/43165 ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค ์ฝ”๋“œ ์ค‘์‹ฌ์˜ ๊ฐœ๋ฐœ์ž ์ฑ„์šฉ. ์Šคํƒ ๊ธฐ๋ฐ˜์˜ ํฌ์ง€์…˜ ๋งค์นญ. ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค์˜ ๊ฐœ๋ฐœ์ž ๋งž์ถคํ˜• ํ”„๋กœํ•„์„ ๋“ฑ๋กํ•˜๊ณ , ๋‚˜์™€ ๊ธฐ์ˆ  ๊ถํ•ฉ์ด ์ž˜ ๋งž๋Š” ๊ธฐ์—…๋“ค์„ ๋งค์นญ ๋ฐ›์œผ์„ธ์š”. programmers.co.kr ๋ฌธ์ œ ํ•ด๊ฒฐ ํฌ์ธํŠธ - Queue๋ฅผ ์ด์šฉํ•˜์—ฌ BFS๋กœ ํƒ์ƒ‰ - ๋ชจ๋“  numbers์˜ ์š”์†Œ์— ๋Œ€ํ•ด์„œ +์™€ -๋ฅผ ์กฐํ•ฉํ•˜๋‹ค๊ฐ€ ๋ชจ๋“  ์ˆ˜๋ฅผ ์‚ฌ์šฉํ–ˆ๋‹ค๋ฉด ๊ทธ ๋•Œ target๊ณผ ๊ฐ’์ด ๊ฐ™์€์ง€ ๋น„๊ต - queue์— ๊ณ„์‚ฐ๋œ ๊ฐ’๊ณผ ์‚ฌ์šฉ๋œ ์ˆซ์ž ๊ฐœ์ˆ˜๋ฅผ ๊ฐ™์ด ์‚ฝ์ž…ํ•จ์œผ๋กœ์จ ๋ฌดํ•œ๋ฃจํ”„์— ๋น ์ง€์ง€ ์•Š๊ฒŒ ํ•จ - ์ฆ‰ popํ•œ ๊ฒฐ๊ณผ๊ฐ€ ์•„์ง ๋ชจ๋“  ์ˆซ์ž๋ฅผ ์‚ฌ์šฉํ•˜์ง€ ์•Š์•˜๋‹ค๋ฉด ๋‹ค์Œ ์ˆซ์ž๋ฅผ ๋”ํ•˜๊ณ  ..

    [SWEA] ํŒŒ์ด์ฌ 2805. ๋†์ž‘๋ฌผ ์ˆ˜ํ™•ํ•˜๊ธฐ

    ~๋ชฉ์ฐจ~ ๋ฌธ์ œ ๋ฌธ์ œ ํ•ด๊ฒฐ ํฌ์ธํŠธ ์ž‘์„ฑ ์ฝ”๋“œ ๋ฌธ์ œ https://swexpertacademy.com/main/code/problem/problemDetail.do?problemLevel=3&contestProbId=AV7GLXqKAWYDFAXB&categoryId=AV7GLXqKAWYDFAXB&categoryType=CODE&problemTitle=&orderBy=RECOMMEND_COUNT&selectCodeLang=PYTHON&select-1=3&pageSize=10&pageIndex=1 SW Expert Academy SW ํ”„๋กœ๊ทธ๋ž˜๋ฐ ์—ญ๋Ÿ‰ ๊ฐ•ํ™”์— ๋„์›€์ด ๋˜๋Š” ๋‹ค์–‘ํ•œ ํ•™์Šต ์ปจํ…์ธ ๋ฅผ ํ™•์ธํ•˜์„ธ์š”! swexpertacademy.com ๋ฌธ์ œ ํ•ด๊ฒฐ ํฌ์ธํŠธ Q. ๋งˆ๋ฆ„๋ชจ๋ฅผ ์–ด๋–ป๊ฒŒ ๊ตฌ๋ถ„ํ•˜์—ฌ ์ฐพ์•„๋‚ผ ๊ฒƒ์ธ๊ฐ€ - ๋†์žฅ์€ ..

    [Python] ๋ฐฑ์ค€ 9663 N-Queen | ์‹œ๊ฐ„์ดˆ๊ณผ

    ์ •๋‹ต์€ ์•Œ๋งž๊ฒŒ ๋‚˜์˜ค๋Š”๋ฐ ์ž๊พธ ์‹œ๊ฐ„์ดˆ๊ณผ๊ฐ€ ๋‚˜์˜ค๋Š” ๋ถ„๋“ค์€ ์–ธ์–ด๋ฅผ Python3๊ฐ€ ์•„๋‹Œ Pypy3๋กœ ์„ค์ •ํ•˜๊ณ  ์‹คํ–‰ํ•ด๋ณด์‹œ๊ธฐ ๋ฐ”๋ž๋‹ˆ๋‹ค ~๋ชฉ์ฐจ~ ๋ฌธ์ œ ๋ฌธ์ œ ํ•ด๊ฒฐ ํฌ์ธํŠธ ์ž‘์„ฑ ์ฝ”๋“œ ๋ฌธ์ œ ์ „ํ˜•์ ์ธ Backtracking ๋ฌธ์ œ์ž…๋‹ˆ๋‹ค! https://www.acmicpc.net/problem/9663 9663๋ฒˆ: N-Queen N-Queen ๋ฌธ์ œ๋Š” ํฌ๊ธฐ๊ฐ€ N × N์ธ ์ฒด์ŠคํŒ ์œ„์— ํ€ธ N๊ฐœ๋ฅผ ์„œ๋กœ ๊ณต๊ฒฉํ•  ์ˆ˜ ์—†๊ฒŒ ๋†“๋Š” ๋ฌธ์ œ์ด๋‹ค. N์ด ์ฃผ์–ด์กŒ์„ ๋•Œ, ํ€ธ์„ ๋†“๋Š” ๋ฐฉ๋ฒ•์˜ ์ˆ˜๋ฅผ ๊ตฌํ•˜๋Š” ํ”„๋กœ๊ทธ๋žจ์„ ์ž‘์„ฑํ•˜์‹œ์˜ค. www.acmicpc.net ๋ฌธ์ œ ํ•ด๊ฒฐ ํฌ์ธํŠธ 1. row[i] : i๋ฒˆ์งธ ํ–‰์—์„œ ํ€ธ์˜ ์—ด ๊ฐ’์„ ๋‚˜ํƒ€๋‚ด๋Š” 1์ฐจ์› ๋ฐฐ์—ด row๋ฅผ ์‚ฌ์šฉํ•จ์œผ๋กœ ๋ฉ”๋ชจ๋ฆฌ ๋‚ญ๋น„ ๋ฐฉ์ง€ 2. promising ํ•จ์ˆ˜ : ๋Œ€๊ฐ์„ ์— ์œ„์น˜ํ•˜๊ฑฐ๋‚˜ ๊ฐ™์€ ์—ด์— ์œ„์น˜ํ•˜๋Š”..

    [SWEA] 1928. Base64 Decoder | ์•„์Šคํ‚ค ์ฝ”๋“œ | ๋น„ํŠธ ์—ฐ์‚ฐ

    https://swexpertacademy.com/main/code/problem/problemDetail.do?problemLevel=2&contestProbId=AV5PR4DKAG0DFAUq&categoryId=AV5PR4DKAG0DFAUq&categoryType=CODE&problemTitle=&orderBy=PASS_RATE&selectCodeLang=PYTHON&select-1=2&pageSize=10&pageIndex=1 SW Expert Academy SW ํ”„๋กœ๊ทธ๋ž˜๋ฐ ์—ญ๋Ÿ‰ ๊ฐ•ํ™”์— ๋„์›€์ด ๋˜๋Š” ๋‹ค์–‘ํ•œ ํ•™์Šต ์ปจํ…์ธ ๋ฅผ ํ™•์ธํ•˜์„ธ์š”! swexpertacademy.com [๋ฌธ์ œ ์ดํ•ดํ•˜๊ธฐ] 1. 24bit ๋ฒ„ํผ์— 1byte์”ฉ 3byte ๋ฌธ์ž๋ฅผ ์ง‘์–ด๋„ฃ๋Š”๋‹ค. => ํ•œ ๋ฌธ์ž ๋‹น 8bit์˜ ํฌ๊ธฐ๋ฅผ ๊ฐ€์ง€๊ณ , 24..

    [Programmers] ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค ์ด์ƒํ•œ ๋ฌธ์ž ๋งŒ๋“ค๊ธฐ | Level 1

    ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค https://school.programmers.co.kr/learn/courses/30/lessons/12930#qna ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค ์ฝ”๋“œ ์ค‘์‹ฌ์˜ ๊ฐœ๋ฐœ์ž ์ฑ„์šฉ. ์Šคํƒ ๊ธฐ๋ฐ˜์˜ ํฌ์ง€์…˜ ๋งค์นญ. ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค์˜ ๊ฐœ๋ฐœ์ž ๋งž์ถคํ˜• ํ”„๋กœํ•„์„ ๋“ฑ๋กํ•˜๊ณ , ๋‚˜์™€ ๊ธฐ์ˆ  ๊ถํ•ฉ์ด ์ž˜ ๋งž๋Š” ๊ธฐ์—…๋“ค์„ ๋งค์นญ ๋ฐ›์œผ์„ธ์š”. programmers.co.kr ํ…Œ์ŠคํŠธ ์ผ€์ด์Šค๋Š” ๋งž๋Š”๋ฐ ์ œ์ถœ์‹œ ์ „๋ถ€ ํ‹€๋ฆฌ๋Š” ๊ฒฝ์šฐ๊ฐ€ ๋ฐœ์ƒํ–ˆ๋‹ค.. ๋‚˜์™€ ๊ฐ™์€ ๊ฒฝ์šฐ๋กœ ์ด ๊ธ€์„ ์ฝ์œผ์‹œ๋Š” ๋ถ„๊ป˜๋Š” ๋‹ค์Œ ํ…Œ์ŠคํŠธ์ผ€์ด์Šค๋ฅผ ์ถ”๊ฐ€ํ•ด์„œ ์‹คํ–‰ํ•ด๋ณด์‹œ๊ธฐ ๋ฐ”๋ž€๋‹ค. ์ž…๋ ฅ : " Try HeLLo wORld " ์ถœ๋ ฅ : " TrY HeLlo WoRlD " def solution(s): alist = s.split(" ") result = '' for a in alist: for i, b ..

    [Python] ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค ํƒ€๊ฒŸ ๋„˜๋ฒ„ | ๋„ˆ๋น„ ์šฐ์„  ํƒ์ƒ‰(BFS)

    https://school.programmers.co.kr/learn/courses/30/lessons/43165 [ํƒ€๊ฒŸ ๋„˜๋ฒ„] level 2 ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค ์ฝ”๋“œ ์ค‘์‹ฌ์˜ ๊ฐœ๋ฐœ์ž ์ฑ„์šฉ. ์Šคํƒ ๊ธฐ๋ฐ˜์˜ ํฌ์ง€์…˜ ๋งค์นญ. ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค์˜ ๊ฐœ๋ฐœ์ž ๋งž์ถคํ˜• ํ”„๋กœํ•„์„ ๋“ฑ๋กํ•˜๊ณ , ๋‚˜์™€ ๊ธฐ์ˆ  ๊ถํ•ฉ์ด ์ž˜ ๋งž๋Š” ๊ธฐ์—…๋“ค์„ ๋งค์นญ ๋ฐ›์œผ์„ธ์š”. programmers.co.kr from collections import deque def solution(numbers, target): que = deque() que.append((1, numbers[0])) que.append((1, -numbers[0])) result = 0 while que: q = que.popleft() if q[0] == len(numbers): if q[1] ==..

    [Python] ๋ฐฑ์ค€ 10819 ์ฐจ์ด๋ฅผ ์ตœ๋Œ€๋กœ | ์ˆœ์—ด/์กฐํ•ฉ | Permutations/Combinations

    ~์‹ค๋ฒ„ 2~ ๋ฐฑํŠธ๋ž˜ํ‚น(Backtracking) ์•Œ๊ณ ๋ฆฌ์ฆ˜์„ ํ•™์Šตํ•˜๋Š” ๊ณผ์ •์—์„œ ๋งŒ๋‚œ ๋ฐฑ์ค€ ๋ฌธ์ œ! https://www.acmicpc.net/problem/10819 10819๋ฒˆ: ์ฐจ์ด๋ฅผ ์ตœ๋Œ€๋กœ ์ฒซ์งธ ์ค„์— N (3 ≤ N ≤ 8)์ด ์ฃผ์–ด์ง„๋‹ค. ๋‘˜์งธ ์ค„์—๋Š” ๋ฐฐ์—ด A์— ๋“ค์–ด์žˆ๋Š” ์ •์ˆ˜๊ฐ€ ์ฃผ์–ด์ง„๋‹ค. ๋ฐฐ์—ด์— ๋“ค์–ด์žˆ๋Š” ์ •์ˆ˜๋Š” -100๋ณด๋‹ค ํฌ๊ฑฐ๋‚˜ ๊ฐ™๊ณ , 100๋ณด๋‹ค ์ž‘๊ฑฐ๋‚˜ ๊ฐ™๋‹ค. www.acmicpc.net [์ตœ์ข… ์ฝ”๋“œ] from itertools import permutations n = int(input()) alist = list(map(int, input().split())) maxN = 0 nPr = permutations(alist) for p in nPr: temp = 0 for i in range(n-1): ..