Skip to content

Commit 10f3b5c

Browse files
Add files via upload
1 parent a93a24e commit 10f3b5c

File tree

3 files changed

+97
-0
lines changed

3 files changed

+97
-0
lines changed

Day14/HidePhoneNumber.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# 35. 핸드폰 번호 가리기
2+
3+
def solution(phone_number):
4+
answer = ''
5+
6+
for i in range(len(phone_number)):
7+
if i < len(phone_number) - 4:
8+
answer += '*'
9+
else:
10+
answer += phone_number[i]
11+
return answer
12+
13+
phone_number1 = '01033334444'
14+
phone_number2 = '027778888'
15+
16+
print(solution(phone_number1))
17+
print(solution(phone_number2))
18+
19+
def solution_best(phone_number):
20+
answer = '*' * (len(phone_number) - 4) + phone_number[-4:]
21+
22+
return answer
23+
24+
print(solution_best(phone_number1))
25+
print(solution_best(phone_number2))

Day14/SumOfMatrix.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# 27. 행렬의 덧셈
2+
import numpy as np
3+
4+
def solution(arr1, arr2):
5+
answer = []
6+
7+
tmp = []
8+
for a, b in zip(arr1, arr2):
9+
for c, d in zip(a, b):
10+
tmp.append(c + d)
11+
answer.append(tmp)
12+
tmp = []
13+
return answer
14+
15+
arr1_1 = [[1, 2], [2, 3]]
16+
arr1_2 = [[1], [2]]
17+
18+
arr2_1 = [[3, 4], [5, 6]]
19+
arr2_2 = [[3], [4]]
20+
21+
print(solution(arr1_1, arr2_1))
22+
print(solution(arr1_2, arr2_2))
23+
print()
24+
25+
def solution_other(arr1, arr2):
26+
answer = [[c + d for c, d in zip(a, b)] for a, b in zip(arr1, arr2)]
27+
28+
return answer
29+
30+
# print(solution_other(arr1_1, arr1_2))
31+
# print(solution_other(arr2_1, arr2_2))
32+
# print()
33+
34+
# 내 풀이
35+
def solution_best(arr1, arr2):
36+
A = np.array(arr1)
37+
B = np.array(arr2)
38+
39+
answer = A + B
40+
return answer
41+
42+
# print(solution_best(arr1_1, arr1_2))
43+
# print(solution_best(arr2_1, arr2_2))

Day14/nCountNumberPeriodx.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# 36. x만큼 간격이 있는 n개의 숫자
2+
3+
def solution(x, n):
4+
answer = []
5+
6+
for i in range(1, n + 1):
7+
answer.append(x * i)
8+
return answer
9+
10+
x_1 = 2
11+
x_2 = 4
12+
x_3 = -4
13+
14+
n_1 = 5
15+
n_2 = 3
16+
n_3 = 2
17+
18+
print(solution(x_1, n_1))
19+
print(solution(x_2, n_2))
20+
print(solution(x_3, n_3))
21+
22+
def solution_best(x, n):
23+
answer = [i * x for i in range(1, n + 1)]
24+
25+
return answer
26+
27+
print(solution_best(x_1, n_1))
28+
print(solution_best(x_2, n_2))
29+
print(solution_best(x_3, n_3))

0 commit comments

Comments
 (0)