Skip to content

Commit 9cde228

Browse files
committed
내 풀이
2 parents 8995674 + 5afa297 commit 9cde228

10 files changed

+130
-0
lines changed

git.sh

+1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ echo Easy Github push generator
33
echo Enter Commit Tilte:
44
read commit
55

6+
67
git add . && git commit -m "$commit"

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
"type": "git",
1212
"url": "git+https://github.com/seongdong2/codeingtest.git"
1313
},
14+
1415
"author": "dong",
1516
"license": "ISC",
1617
"bugs": {

연습 예제 모음/217.py

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<<<<<<< HEAD
2+
=======
3+
x = int(input())
4+
d = [0]*10000
5+
6+
for i in range(2, x+1):
7+
d[i] = d[i-1]-1
8+
if i%5==0 :
9+
d[i] = min(d[i], (d[i]//5)+1)
10+
if i%2==0 :
11+
d[i] = min(d[i], (d[i]//2)+1)
12+
if i%3==0 :
13+
d[i] = min(d[i], (d[i]//2)+1)
14+
15+
print(d[x])
16+
17+
18+
19+
20+
21+
22+
23+
24+
>>>>>>> 5afa297714be941bb636a1583240760aedfc8610

정리.py

+4
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ def bfs(gragh, start, visited):
2222
queue.append(i)
2323
visited[i] = True
2424

25+
2526
#선택정렬, O(N**2)
2627
array = []
2728
for i in range(len(array)) :
@@ -39,13 +40,16 @@ def bfs(gragh, start, visited):
3940
else :
4041
break
4142

43+
<<<<<<< HEAD
4244
for i in range(1, len(array)):
4345
for j in range(i, 0, -1):
4446
if array[j] > array[j-1]:
4547
array[j], array[j-1] = array[j-1], array[j]
4648
else:
4749
break
4850

51+
=======
52+
>>>>>>> 5afa297714be941bb636a1583240760aedfc8610
4953

5054
#퀵 정렬, O(NlogN)
5155
def quick(array):
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#array의 각 element 중 divisor로 나누어 떨어지는 값을 오름차순으로 정렬한 배열을 반환하는 함수, solution을 작성해주세요.
2+
#divisor로 나누어 떨어지는 element가 하나도 없다면 배열에 -1을 담아 반환하세요.
3+
4+
def solution(arr, divisor):
5+
answer = []
6+
for element in arr:
7+
if element%divisor ==0:
8+
answer.append(element)
9+
10+
answer.sort()
11+
12+
return answer if len(answer) > 0 else [-1]

프로그래머스/1_시저 암호.py

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#어떤 문장의 각 알파벳을 일정한 거리만큼 밀어서 다른 알파벳으로 바꾸는 암호화 방식을 시저 암호라고 합니다. 예를 들어 "AB"는 1만큼 밀면 "BC"가 되고, 3만큼 밀면 "DE"가 됩니다. "z"는 1만큼 밀면 "a"가 됩니다. 문자열 s와 거리 n을 입력받아 s를 n만큼 민 암호문을 만드는 함수, solution을 완성해 보세요.
2+
3+
def solution(s, n):
4+
answer = ''
5+
for c in s:
6+
if c == ' ':
7+
answer += ' '
8+
continue
9+
scissor = ord(c) + n
10+
if (ord(c) in range(ord('A'), ord('Z')+1) & scissor > ord('Z')) or (ord(c) in range(ord('a'), ord('z')+1) & scissor > ord('z')):
11+
answer += chr(scissor-26)
12+
else:
13+
answer += chr(scissor)
14+
return answer
15+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#약수의 갯수가 홀수인 경우는 제곱수인 경우 뿐이다.
2+
def solution(left, right):
3+
answer = 0
4+
for i in range(left, right+1):
5+
if isEven(i) : answer +=1
6+
else :answer -= 1
7+
return answer
8+
9+
#1/2 제곱수가 정수면 > 홀수의 약수 갯수를 가지게 됌.
10+
def isEven(num):
11+
return True if (num**(1/2))%1 > 0 else False

프로그래머스/1_체육복.py

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
def solution(n, lost, reserve):
2+
def bollow(array, x):
3+
if array[x] != 0:
4+
array[x] = 0
5+
return True
6+
else : False
7+
8+
#도난당한 친구들만큼 빼주기
9+
answer = n-len(lost)
10+
chk = [0] * (n+1)
11+
12+
#여벌 체육복 가져온 친구들 reserver
13+
for num in reserve:
14+
chk[num] += 1
15+
16+
17+
for i in range(1, n+1) :
18+
if i in lost :
19+
if bollow(chk, i-1) or bollow(chk, i+1):
20+
answer +=1
21+
22+
return answer

프로그래머스/2_튜플.py

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#셀수있는 수량의 순서있는 열거 또는 어떤 순서를 따르는 요소들의 모음을 튜플(tuple)이라고 합니다. n개의 요소를 가진 튜플을 n-튜플(n-tuple)이라고 하며, 다음과 같이 표현할 수 있습니다.
2+
3+
4+
def solution(s):
5+
answer = num(s)
6+
#answer = []
7+
return answer
8+
9+
def num(x):
10+
_num = []
11+
list_num = []
12+
13+
for i in range(len(x)):
14+
if x[i] == '{' or x[i] =='}':
15+
continue
16+
17+
if x[i] == ',' and x[i-1] == '}' and x[i+1]=='{' :
18+
list_num.append(_num)
19+
_num = []
20+
21+
if x[i] != ',':
22+
_num.append(int(x[i]))
23+
24+
list_num.append(_num)
25+
return list_num
+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#피보나치 수는 F(0) = 0, F(1) = 1일 때, 1 이상의 n에 대하여 F(n) = F(n-1) + F(n-2) 가 적용되는 수 입니다.
2+
3+
def solution(n):
4+
answer = 0
5+
answer = fibo(n)%1234567
6+
print(fibo(n))
7+
return answer
8+
9+
def fibo(n):
10+
d=[0]*10000001
11+
d[1] = 1
12+
d[2] = 1
13+
for i in range(3, n+1) :
14+
d[i]=d[i-1]+d[i-2]
15+
return d[n]

0 commit comments

Comments
 (0)