Skip to content

Commit 2630120

Browse files
authored
Add files via upload
1 parent 0edb6ec commit 2630120

File tree

3 files changed

+58
-0
lines changed

3 files changed

+58
-0
lines changed

Day13/CollatzPredict.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
def solution(num):
2+
answer = 0
3+
4+
for i in range(500):
5+
if num == 1:
6+
return answer
7+
else:
8+
if num % 2 == 0:
9+
num = num // 2
10+
answer += 1
11+
else:
12+
num = num * 3 + 1
13+
answer += 1
14+
return -1
15+
16+
n1 = 6
17+
n2 = 16
18+
n3 = 626331
19+
20+
print(solution(n1))
21+
print(solution(n2))
22+
print(solution(n3))

Day13/KakaoTest2019.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
def solution(board, moves):
2+
basket = []
3+
answer = 0
4+
for j in moves:
5+
for i in range(len(board)):
6+
if board[i][j-1] != 0:
7+
basket.append(board[i][j-1])
8+
board[i][j-1] = 0
9+
10+
if len(basket) >= 2:
11+
while (basket[-1] == basket[-2]):
12+
basket.pop()
13+
basket.pop()
14+
answer += 2
15+
if len(basket) < 2:
16+
break
17+
break
18+
return answer
19+
20+
board = [[0,0,0,0,0],[0,0,1,0,3],[0,2,5,0,1],[4,2,4,4,2],[3,5,1,3,1]]
21+
moves = [1,5,3,5,1,2,1,4]
22+
23+
print(solution(board, moves))

Day13/NomberOfHashade.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
def solution(x):
2+
answer = x % sum([int(i) for i in str(x)]) == 0
3+
return answer
4+
5+
arr1 = 10
6+
arr2 = 12
7+
arr3 = 11
8+
arr4 = 13
9+
10+
print(solution(arr1))
11+
print(solution(arr2))
12+
print(solution(arr3))
13+
print(solution(arr4))

0 commit comments

Comments
 (0)