๐
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import torch | |
import torch.nn as nn | |
from torchensemble import VotingClassifier | |
from sklearn.datasets import make_classification | |
from sklearn.model_selection import train_test_split | |
from sklearn.preprocessing import StandardScaler | |
import numpy as np | |
from skorch import NeuralNetClassifier | |
from sklearn.ensemble import VotingClassifier as SklearnVotingClassifier |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
from sklearn.ensemble import VotingClassifier | |
from sklearn.datasets import make_classification | |
from sklearn.model_selection import train_test_split, cross_val_score | |
from sklearn.preprocessing import StandardScaler | |
from skorch import NeuralNetClassifier | |
import torch | |
import torch.nn as nn | |
# ์ํ ๋ฐ์ดํฐ ์์ฑ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from random import randint | |
def bubble_sort(arr): | |
n = len(arr) | |
for i in range(n): | |
done_sort = True | |
for j in range(n - i - 1): | |
if arr[j] > arr[j + 1]: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
๋ฌธ์ : ์ต์ฅ ๊ณตํต ๋ถ๋ ์์ด (Longest Common Subsequence) | |
- ๋ ๋ฌธ์์ด (str1, str2)๊ฐ ์ฃผ์ด์ก์ ๋ ํด๋น ๋ ๋ฌธ์์ด์ ์ต์ฅ ๊ณตํต ์์ด์ ๊ธธ์ด๋ฅผ ๋ฐํํ๋ผ. | |
- ์ด ๋ฌธ์ ์์ ์ธ๊ธํ๋ ๋ถ๋ถ ์์ด์ ์ฐ์์ ์ด์ง ์์ผ๋ ์์๋๋ก ๋์ด ๋ ์ ์๋ ๋ฌธ์์ด์ ๋งํ๋ค. | |
- ์๋ฅผ ๋ค์ด์ 'abcde' ๋ผ๋ ๋ฌธ์์ด์์ ๋ถ๋ถ ์์ด์ 'abc', 'ace', 'aed' ๋ฑ ๊ฐ ๋ฌธ์์ ์์๋ฅผ ์งํจ ๋ชจ๋ ๋ถ๋ถ ๋ฌธ์์ด์ ๋งํ๋ค. | |
### ์์ด๋์ด (Brute-Force) | |
1 str1์ ์ธ๋ฑ์ค i, str2์ ์ธ๋ฑ์ค j๋ฅผ 0์ผ๋ก ์ด๊ธฐํ ํ๋ค. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
# ๋ฌธ์ : ๋์ ๊ตํ | |
๊ฐ๊ธฐ ๋ค๋ฅธ ์ก๋ฉด์ ๊ฐ์ง ๋์ ๋ฐฐ์ด๊ณผ ๊ฑฐ์ฌ๋ฌ์ฃผ์ด์ผ ํ๋ ์ด ๊ธ์ก์ ์ ๋ ฅ์ผ๋ก ๋ฐ์ผ๋ฉด ์๋์ ์กฐํฉ์ผ๋ก ๊ฑฐ์ค๋ฆ๋์ ๋ง์ถฐ์ฃผ๊ธฐ ์ํ ์ต์ํ์ | |
๋์ ๊ฐ์๋ฅผ ๋ฐํํ์. | |
์๋ฅผ ๋ค์ด์ [1, 5, 10, 25] ์ก๋ฉด์ ๋์ ์ด ์๋ค๊ณ ํ ๋, ๊ฑฐ์ค๋ฆ๋์ด 1์ด๋ผ๋ฉด ์ก๋ฉด 1์ธ ๋์ ํ๋๋ง ์์ผ๋ฉด ๋๋ค. | |
### ์์ด๋์ด (Brute-Force) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
# ๋ฌธ์ 7.2: ๋์ผ ํฉ์ผ๋ก ๋ฐฐ์ด ๋ถํ ๋ฌธ์ | |
์์ ์ ์๋ก ๊ตฌ์ฑ๋ ๋ฐฐ์ด์ด ์ฃผ์ด์ง๋ฉด, ํด๋น ๋ฐฐ์ด์ ๋ ๋ถ๋ถ์ผ๋ก ๋ถํ ํ์ฌ ๋์ผํ ํฉ์ ๊ฐ์ ๊ฐ์ง๋์ง ํ์ธํด๋ณด๋ผ. | |
์๋ฅผ ๋ค์ด์, [1, 2, 3, 4]๊ฐ ์๊ณ [1, 4], [2, 3]์ผ๋ก ๋ถํ ํ๋ฉด ๊ฐ ๋ถํ ๋ ๋ฐฐ์ด ์์์ ํฉ์ด 5๋ก ๋์ผํ๋ค. | |
### ์์ด๋์ด (Brute-Force) | |
1. ๋ฐฐ์ด์ ์ ์ฒด ํฉ์ 2๋ก ๋๋๋ค. | |
2. ์ ์ฒด ํฉ์ด 2๋ก ๋๋ ๋๋จธ์ง๊ฐ 0์ด ์๋๋ผ๋ฉด ๋ฐ๋ก ๊ฑฐ์ง(False)์ ๋ฐํ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
# ๋ฌธ์ : ๋ฐฐ๋ญ ๋ฌธ์ | |
items = {๋ฌผ, ํต์กฐ๋ฆผ, ๋ผ๋์ค, ๊ตฌ๊ธ์ฝ} | |
values = {7, 5, 3, 4} | |
weights = {2, 1, 3, 4} | |
๋ฐฐ๋ญ์๋ ๋ฌด๊ฒ 5๋งํผ์ ๋ฃ์ ์ ์๊ณ , ๋ ์ด์์ ๋ฃ์ ์ ์๋ค. | |
๋ค์ํ ์กฐํฉ์ด ๊ฐ๋ฅํ๋ฐ, ๊ทธ์ค์์ ๊ฐ์ฅ ๊ฐ์น๊ฐ ๋์ ์กฐํฉ์ ๊ตฌํ๋ผ. | |
""" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
# ๋ฌธ์ : ์ด์ง ํธ๋ฆฌ ๊ฒ์ฆ | |
์ฃผ์ด์ง ์ด์ง ๊ฒ์ ํธ๋ฆฌ๊ฐ ์ด์ง ํธ๋ฆฌ์ ์กฐ๊ฑด์ ๋ง์กฑํ๋์ง ์๋์ง๋ฅผ ํ์ธํ๋ผ. | |
- ์ด์ง ํธ๋ฆฌ๋ ๋ถ๋ชจ ๋ ธ๋๋ฅผ ๊ธฐ์ค์ผ๋ก ์ผ์ชฝ ๋ ธ๋๋ ๋ถ๋ชจ ๋ ธ๋๋ณด๋ค ์์ ๊ฐ์ด ๋ณด์ฅ๋๊ณ | |
- ์ค๋ฅธ์ชฝ ๋ ธ๋๋ ํด๋น ๋ ธ๋๋ณด๋ค ํญ์ ํฐ ๊ฐ์ด๋ผ๋ ๋ณด์ฅ์ด ๋๋ค. | |
### ์์ด๋์ด (์ฌ๊ท) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
# ๋ฌธ์ : ์ด์ง ํธ๋ฆฌ ๋ฐ์ | |
ํธ๋ฆฌ์ ๋ฃจํธ๋ฅผ ๊ธฐ์ค์ผ๋ก ์ข์ฐ ๋ ธ๋๋ฅผ ๋ฐ๊พธ๋ ์ฝ๋๋ฅผ ์์ฑํ๋ผ. | |
### ์์ด๋์ด (๋ฐ๋ณต - ์คํ) | |
1. ์คํ ์์ฑ | |
2. ๋ฃจํธ ๋ ธ๋๋ฅผ ์คํ์ ์ถ๊ฐ | |
3. ์คํ์ด ๋น์ด์์ ๋ ๊น์ง |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
# ๋ฌธ์ : 3๋ฒ์งธ ํฐ ์ | |
- ๋ฐฐ์ด์์ 3๋ฒ์ฌ๋ก ํฐ ์๋ฅผ ์ฐพ์์ ๋ฐํํ๋๋ก ํ์. | |
- ๋ง์ฝ 3๋ฒ์งธ๋ก ํฐ ์๊ฐ ์๋ค๋ฉด ๊ฐ์ฅ ํฐ ์๋ฅผ ๋ฐํํ๋ฉด ๋๋ค. ์๋ฅผ ๋ค์ด์ ๋ฐฐ์ด์ [1, 2, 3] ์ด ์๋ค๋ฉด 1์ ๋ฐํํ๊ณ | |
3๋ฒ์งธ๊ฐ ์๋ ๋ฐฐ์ด [2, 3] ์ด๋ผ๋ฉด 3์ ๋ฐํํ๋ฉด ๋๋ค. | |
### ์์ด๋์ด (์ ๋ ฌ) | |
1. ๋ฐฐ์ด์ ์ญ์์ผ๋ก ์ ๋ ฌํ๋ค. |
NewerOlder