Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .DS_Store
Binary file not shown.
10 changes: 10 additions & 0 deletions .idea/Devils_Algorithm.iml

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

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

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

7 changes: 7 additions & 0 deletions .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 .idea/modules.xml

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

40 changes: 31 additions & 9 deletions .idea/workspace.xml

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

Binary file added Devil_C/.DS_Store
Binary file not shown.
Binary file added Devil_C/week01_recursion/.DS_Store
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,4 @@ void search(Node n) {

System.out.println(n.key);
}
}
}gi
Binary file added Devil_Python/.DS_Store
Binary file not shown.
Binary file added Devil_Python/week01_recursion/.DS_Store
Binary file not shown.
108 changes: 108 additions & 0 deletions Devil_Python/week02_recursion/gold/BOJ12100.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
import sys

board = []

N = int(sys.stdin.readline().strip()) #\n 없애기 .strip()

#board 만들어
for row in range(N):
line = sys.stdin.readline().split()
values = []
for x in line:
values.append(int(x))
board.append(values)


#왼쪽 기준
def sum_line(line):

new_line = []
for k in line:
if k != 0:
new_line.append(k)

result = []

combined = False #합쳐진거 이미 건너뛰어야돼

for i in range(len(new_line)):
if combined:
combined = False
continue
#합쳐졌으면 건너뛰고 다음으로 걍 진행
if i + 1 < len(new_line) and new_line[i] == new_line[i+1]:
result.append(new_line[i] * 2)
combined = True

else:
result.append(new_line[i])

while len(result) < N:
result.append(0)

return result

def move(board, direction):
new_board = []

for k in range(N):
row = []
for j in range(N):
row.append(0)
new_board.append(row)

#왼쪽
if direction == 0:
for i in range(N):
new_board[i] = sum_line(board[i])

#오른쪽
elif direction == 1:
for i in range(N):
new_board[i] = sum_line(board[i][::-1])[::-1] #보드 뒤집어서 하기 왜냐면 왼쪽 기준이니까

#위쪽
#음므믐ㅁㅁ 왼쪽 기준이니까 세로 계산해서 하기
elif direction == 2:
for i in range(N):
col = []
for j in range(N):
col.append(board[j][i])

new_col = sum_line(col)

for j in range(N):
new_board[j][i] = new_col[j]

#아래쪽
#위쪽 뒤짐으면 되지 않나
elif direction == 3:
for i in range(N):
col = []
for j in range(N-1, -1, -1):
col.append(board[j][i])

new_col = sum_line(col)[::-1]

for j in range(N):
new_board[j][i] = new_col[j]

return new_board


#최대 5번까지 해보기 for문 5번?
output = 0
for d1 in range(4):
for d2 in range(4):
for d3 in range(4):
for d4 in range(4):
for d5 in range(4):
directions = [d1, d2, d3, d4, d5]
copy_board = board
for d in directions:
copy_board = move(copy_board, d)
for i in range(N):
output = max(output, max(copy_board[i]))

print(output)

32 changes: 32 additions & 0 deletions Devil_Python/week02_recursion/silver/BOJ16463.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
N = int(input())

month = [31,28,31,30,31,30,31,31,30,31,30,31]


first_day = 1 #화요일 설정 # 0,1,2,3,4,5,6
count = 0


for year in range(2019, N+1):
for m in range(12):

#2월 윤년 계산!
if m == 1:

#400의 배수, 100의 배수가 아니면서 4의 배수
if (year % 400 == 0) or (year % 100 != 0 and year % 4 == 0):
month_days = 29
else:
month_days = 28

else:
month_days = month[m]

#금요일 수 세기
if (first_day + 12) % 7 == 4:
count += 1

#다음 월 시작 요일 계산
first_day = (first_day + month_days) % 7

print(count)
51 changes: 51 additions & 0 deletions Devil_Python/week03_recursion/gold/BOJ1744.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# 합이 최대가 되게 두 수 곱해서 더하기
# 음수, 0, 1, 양수
# 음수는 음수끼리 양수는 양수끼리 / 음수 0하고 곱하기 1은 걍 더하기

N = int(input().strip())
nums = [int(input().strip()) for _ in range(N)]


#nums.sort()

# 음수, 양수, 따로 정렬?

negative = []
zero = 0
one = 0
positive = []
result = 0

for n in nums:
if n > 1:
positive.append(n)
elif n < 0:
negative.append(n)
elif n == 1:
one += 1
elif n == 0:
zero += 1

positive.sort(reverse=True)
negative.sort()

# 두 개씩 묶어서 곱하기 음수, 양수
for i in range(0, len(negative), 2):
if i + 1 < len(negative):
result += negative[i] * negative[i+1]
elif zero == 0:
result += negative[i]

for i in range(0, len(positive), 2):
if i + 1 < len(positive):
result += positive[i] * positive[i+1]
else:
result += positive[i]

result += one

print(result)




21 changes: 21 additions & 0 deletions Devil_Python/week03_recursion/silver/BOJ2217.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
N = int(input().strip())
rope = [int(input().strip()) for _ in range(N)]

Max = 0

# 로프 여러개니까 내림차순 정렬 후 가능한 무게 찾기 (30 ,20, 10)

rope.sort(reverse=True)

for i in range(N):
weight = rope[i] * (i + 1)
Max = max(Max, weight)


print(Max)


# [40, 30, 20, 10]

# rope[0] = 40 x 1 로프 1개
# rope[1] = 30 x 2 60kg 가능