Skip to content

Commit e9a8e66

Browse files
committed
'오답'
1 parent 9eca7a7 commit e9a8e66

30 files changed

+665
-642
lines changed

.vscode/launch.json

+14-14
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
{
2-
// Use IntelliSense to learn about possible attributes.
3-
// Hover to view descriptions of existing attributes.
4-
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5-
"version": "0.2.0",
6-
"configurations": [
7-
{
8-
"name": "Python: Current File",
9-
"type": "python",
10-
"request": "launch",
11-
"program": "${file}",
12-
"console": "integratedTerminal"
13-
}
14-
]
1+
{
2+
// Use IntelliSense to learn about possible attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": [
7+
{
8+
"name": "Python: Current File",
9+
"type": "python",
10+
"request": "launch",
11+
"program": "${file}",
12+
"console": "integratedTerminal"
13+
}
14+
]
1515
}

package.json

+20-20
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
{
2-
"name": "dong",
3-
"version": "1.0.0",
4-
"description": "my node package",
5-
"main": "index.js",
6-
"scripts": {
7-
"test": "echo \"Error: no test specified\" && exit 1",
8-
"git": "bash ./git.sh"
9-
},
10-
"repository": {
11-
"type": "git",
12-
"url": "git+https://github.com/seongdong2/codeingtest.git"
13-
},
14-
"author": "dong",
15-
"license": "ISC",
16-
"bugs": {
17-
"url": "https://github.com/seongdong2/codeingtest/issues"
18-
},
19-
"homepage": "https://github.com/seongdong2/codeingtest#readme"
20-
}
1+
{
2+
"name": "dong",
3+
"version": "1.0.0",
4+
"description": "my node package",
5+
"main": "index.js",
6+
"scripts": {
7+
"test": "echo \"Error: no test specified\" && exit 1",
8+
"git": "bash ./git.sh"
9+
},
10+
"repository": {
11+
"type": "git",
12+
"url": "git+https://github.com/seongdong2/codeingtest.git"
13+
},
14+
"author": "dong",
15+
"license": "ISC",
16+
"bugs": {
17+
"url": "https://github.com/seongdong2/codeingtest/issues"
18+
},
19+
"homepage": "https://github.com/seongdong2/codeingtest#readme"
20+
}
+14-16
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
1-
s = list(map(int, input()))
2-
rst = 0
3-
4-
for i in range(len(s)) :
5-
if s[i] == 0 or rst == 0:
6-
rst += s[i]
7-
else :
8-
rst *= s[i]
9-
10-
print(rst)
11-
12-
#112 >
13-
#11112
14-
#1222222
15-
#2222
16-
#
1+
s = list(map(int, input()))
2+
rst = 0
3+
4+
for i in range(len(s)) :
5+
if s[i] == 0 or rst == 0:
6+
rst += s[i]
7+
else :
8+
rst *= s[i]
9+
10+
print(rst)
11+
12+
#아이디어 : 최대한 곱해줘야 크다
13+
#0일 때 와 앞선 결과가 0일 때, 더하기를 해주고
14+
#나머지는 곱하기를 해준다

그리디 문제/모험가 길드.py

+14-14
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
n = int(input())
2-
array = list(map(int, input().split()))
3-
array.sort()
4-
5-
6-
count = result = 0
7-
for i in array :
8-
result +=1
9-
if result == i :
10-
count += 1
11-
result = 0
12-
13-
14-
1+
n = int(input())
2+
array = list(map(int, input().split()))
3+
array.sort()
4+
5+
6+
count = result = 0
7+
for i in array :
8+
result +=1
9+
if result == i :
10+
count += 1
11+
result = 0
12+
13+
14+
1515
print(count)
+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# 전부 0으로 바꾸는 경우와 전부 1로 바꾸는 경우 중에 더 적은 횟수를 가진 경우를 계산한다.
2+
3+
s = list(map(int, input()))
4+
cnt = 0
5+
rst1 = 0
6+
rst2 = 0
7+
8+
for i in range(len(s)) :
9+
if s[i] and s[i-1] == 1 :
10+
rst1 += 1
11+
elif s[i] and s[i-1] == 0:
12+
rst2 += 1
13+
else :
14+
continue
15+
16+
for i in range(len(s)) :
17+
if s[i-1] :
18+
if s[i] != s[i-1] :
19+
cnt += 1
20+
21+
22+
if rst1 > rst2 :
23+
print(cnt)
24+
else :
25+
print(cnt)

연습 예제 모음/117.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
c = ord('c')
1+
c = ord('c')
22
print(chr(c+1))

연습 예제 모음/118.py

+27-27
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
1-
N, M = map(int, input().split())
2-
d = [[0]*M for i in range(N)]
3-
4-
5-
A, B, d = map(int, input().split())
6-
d[A][B] = 1
7-
8-
array = []
9-
for i in range(N) :
10-
array.append(list(map(int, input().split())))
11-
12-
#북 동 남 서
13-
dx = [-1, 0, 1, 0]
14-
dy = [0, 1, 0, -1]
15-
16-
def t() :
17-
global dir
18-
dir -= 1
19-
if dir == -1 :
20-
dir ==3
21-
22-
count = 1
23-
24-
25-
26-
27-
1+
N, M = map(int, input().split())
2+
d = [[0]*M for i in range(N)]
3+
4+
5+
A, B, d = map(int, input().split())
6+
d[A][B] = 1
7+
8+
array = []
9+
for i in range(N) :
10+
array.append(list(map(int, input().split())))
11+
12+
#북 동 남 서
13+
dx = [-1, 0, 1, 0]
14+
dy = [0, 1, 0, -1]
15+
16+
def t() :
17+
global dir
18+
dir -= 1
19+
if dir == -1 :
20+
dir ==3
21+
22+
count = 1
23+
24+
25+
26+
27+

연습 예제 모음/159.py

+12-12
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
array = [7, 5, 9, 0, 4, 1, 6, 2, 4, 8]
2-
array.sort()
3-
print(array)
4-
5-
for i in range(len(array)) :
6-
n = i
7-
for j in range(i+1, len(array)):
8-
if array[n] > array[j] :
9-
n = j
10-
11-
array[i], array[n] = array[n], array[i]
12-
1+
array = [7, 5, 9, 0, 4, 1, 6, 2, 4, 8]
2+
array.sort()
3+
print(array)
4+
5+
for i in range(len(array)) :
6+
n = i
7+
for j in range(i+1, len(array)):
8+
if array[n] > array[j] :
9+
n = j
10+
11+
array[i], array[n] = array[n], array[i]
12+
1313
print(array)

연습 예제 모음/163.py

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
array = [7, 5, 9, 0, 4, 1, 6, 2, 4, 8]
2-
3-
for i in range(1, len(array)) :
4-
for j in range(i, 0, -1) :
5-
if array[j] > array[j-1] :
6-
array[j] , array[j-1] = array[j-1] , array[j]
7-
8-
9-
else :
1+
array = [7, 5, 9, 0, 4, 1, 6, 2, 4, 8]
2+
3+
for i in range(1, len(array)) :
4+
for j in range(i, 0, -1) :
5+
if array[j] > array[j-1] :
6+
array[j] , array[j-1] = array[j-1] , array[j]
7+
8+
9+
else :
1010
break

연습 예제 모음/168.py

+23-23
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
1-
array = [7, 5, 9, 0, 4, 1, 6, 2, 4, 8]
2-
3-
def quick(array, start, end):
4-
if start >= end :
5-
return
6-
p = start
7-
left = start+1
8-
right = end
9-
while left <= right :
10-
while left <= end and array[left] <= array[p] :
11-
left += 1
12-
while right >= start and array[right] >= array[start]:
13-
right -= 1
14-
if left > right :
15-
array[right], array[p] = array[right], array[p]
16-
else :
17-
array[left], array[right] = array[right], array[left]
18-
19-
quick(array, start, right-1)
20-
quick(array, right+1 , end)
21-
22-
quick(array, 0, len(array)-1 )
23-
print(array)
1+
array = [7, 5, 9, 0, 4, 1, 6, 2, 4, 8]
2+
3+
def quick(array, start, end):
4+
if start >= end :
5+
return
6+
p = start
7+
left = start+1
8+
right = end
9+
while left <= right :
10+
while left <= end and array[left] <= array[p] :
11+
left += 1
12+
while right >= start and array[right] >= array[start]:
13+
right -= 1
14+
if left > right :
15+
array[right], array[p] = array[right], array[p]
16+
else :
17+
array[left], array[right] = array[right], array[left]
18+
19+
quick(array, start, right-1)
20+
quick(array, right+1 , end)
21+
22+
quick(array, 0, len(array)-1 )
23+
print(array)

연습 예제 모음/180-2.py

+16-16
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
n = int(input())
2-
3-
array = []
4-
for i in range(n) :
5-
id = input().split()
6-
array.append((id[0], int(id[1])))
7-
8-
#def setting(data) :
9-
# return data[1]
10-
#result = sorted(array, key=setting)
11-
12-
13-
array = sorted(array, key=lambda result: result[1])
14-
15-
print(array)
16-
for result in array :
1+
n = int(input())
2+
3+
array = []
4+
for i in range(n) :
5+
id = input().split()
6+
array.append((id[0], int(id[1])))
7+
8+
#def setting(data) :
9+
# return data[1]
10+
#result = sorted(array, key=setting)
11+
12+
13+
array = sorted(array, key=lambda result: result[1])
14+
15+
print(array)
16+
for result in array :
1717
print(result[0], end=' ')

연습 예제 모음/180.py

+14-14
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
n = int(input())
2-
3-
array = []
4-
for i in range(n) :
5-
array.append(input().split())
6-
7-
def setting(data) :
8-
return data[1]
9-
10-
result = sorted(array, key=setting)
11-
12-
print(result)
13-
14-
for i in result :
1+
n = int(input())
2+
3+
array = []
4+
for i in range(n) :
5+
array.append(input().split())
6+
7+
def setting(data) :
8+
return data[1]
9+
10+
result = sorted(array, key=setting)
11+
12+
print(result)
13+
14+
for i in result :
1515
print(i[0], end=' ')

0 commit comments

Comments
 (0)