-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
- Loading branch information
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
global cnt | ||
cnt = 0 | ||
|
||
# 주어진 배열, 현재 인덱스, target, now_value | ||
def dfs(numbers, start_idx, target, now_value): | ||
global cnt | ||
if start_idx == len(numbers): | ||
if now_value == target: | ||
cnt += 1 | ||
else: | ||
print('+',numbers[start_idx]) | ||
dfs(numbers, start_idx+1, target, now_value+numbers[start_idx]) | ||
|
||
print('-',numbers[start_idx]) | ||
dfs(numbers, start_idx+1, target, now_value-numbers[start_idx]) | ||
return cnt | ||
|
||
def solution(numbers, target): | ||
answer = dfs(numbers, 0, target, 0) | ||
return answer | ||
# Press the green button in the gutter to run the script. | ||
if __name__ == '__main__': | ||
numbers = [1, 1, 1, 1, 1] | ||
target = 3 | ||
solution(numbers,target) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
from numpy import median | ||
|
||
|
||
def solution(brown, yellow): | ||
s_answer = [] | ||
# yellow의 약수 구하기 | ||
yak_list = [int(i) for i in range(1, yellow+1) if yellow % i == 0] | ||
if len(yak_list) % 2 == 0: | ||
while len(yak_list): | ||
x = yak_list.pop() | ||
y = yak_list.pop(0) | ||
if (x+2)*(y+2)-(x*y) == brown: | ||
s_answer.append(int(x+2)) | ||
s_answer.append(int(y+2)) | ||
return s_answer | ||
else: | ||
while len(yak_list): | ||
if len(yak_list) == 1: | ||
x = median(yak_list) | ||
y = x | ||
else: | ||
x = yak_list.pop() | ||
y = yak_list.pop(0) | ||
if (x+2)*(y+2)-(x*y) == brown: | ||
s_answer.append(int(x+2)) | ||
s_answer.append(int(y+2)) | ||
return s_answer | ||
|
||
|
||
if __name__ == '__main__': | ||
answer = solution(8, 1) | ||
print('출력값: ', answer) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# This is a sample Python script. | ||
|
||
# Press Shift+F10 to execute it or replace it with your code. | ||
# Press Double Shift to search everywhere for classes, files, tool windows, actions, and settings. | ||
|
||
|
||
def print_hi(name): | ||
# Use a breakpoint in the code line below to debug your script. | ||
print(f'Hi, {name}') # Press Ctrl+F8 to toggle the breakpoint. | ||
|
||
|
||
# Press the green button in the gutter to run the script. | ||
if __name__ == '__main__': | ||
print_hi('PyCharm') | ||
|
||
# See PyCharm help at https://www.jetbrains.com/help/pycharm/ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# 깃허브 1일 1커밋 시작! | ||
|