Skip to content

Commit

Permalink
programmers carpet문제
Browse files Browse the repository at this point in the history
  • Loading branch information
sunyeongchoi committed Sep 8, 2020
0 parents commit fef9cca
Show file tree
Hide file tree
Showing 10 changed files with 110 additions and 0 deletions.
3 changes: 3 additions & 0 deletions argorithm/.idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions argorithm/.idea/argorithm.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions argorithm/.idea/inspectionProfiles/profiles_settings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions argorithm/.idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions argorithm/.idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions argorithm/.idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 25 additions & 0 deletions argorithm/best_albumn.py
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)
32 changes: 32 additions & 0 deletions argorithm/carpet.py
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)
16 changes: 16 additions & 0 deletions argorithm/main.py
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/
2 changes: 2 additions & 0 deletions markdown/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# 깃허브 1일 1커밋 시작!

0 comments on commit fef9cca

Please sign in to comment.