Skip to content

Commit 9e55cda

Browse files
authored
Merge pull request #252 from Suxxxxhyun/Suxxxxhyun
[Failed] PRG_롤케이크 자르기(복습필요), [Solved] PRG_음양더하기
2 parents e637b80 + 20d0081 commit 9e55cda

File tree

7 files changed

+118
-4
lines changed

7 files changed

+118
-4
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Counter(리스트)
2+
# {1:4, 2:3}와 같은 형식으로 변함
3+
# 딕셔너리에서 원소를 제거하는 방법은 2가지이다.
4+
# del 딕셔너리[키]
5+
# 딕셔너리.pop(키) -> pop을 사용하면 해당 키를 제거할때, 그 키에 해당하는 value를 반환한다.
6+
from collections import Counter
7+
def solution(topping):
8+
answer = 0
9+
old = Counter(topping)
10+
young = set()
11+
12+
for t in topping:
13+
old[t] -= 1
14+
young.add(t)
15+
16+
if old[t] == 0:
17+
del old[t]
18+
if len(old) == len(young):
19+
answer += 1
20+
21+
return answer
22+
23+
topping = [1, 2, 1, 3, 1, 4, 1, 2]
24+
# topping = [1, 2, 3, 1, 4]
25+
print(solution(topping))

Week5/공통/음양_더하기/suhyun.py

Whitespace-only changes.

Week5/공통/음양_더하기/test.java

-4
This file was deleted.

Week6/개인/n과m4/suhyun1.py

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from itertools import combinations_with_replacement
2+
n, m = map(int, input().split())
3+
answers = list(combinations_with_replacement(range(1, n+1), m))
4+
for e in answers:
5+
print(' '.join(map(str, e)))
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package Week6.개인.분수최소개수구하기;
2+
3+
public class suhyun {
4+
public static int solution(int n, int[] locations){
5+
int max = 0, min = 100001, count = 0;
6+
for(int i=0; i<locations.length; i++){
7+
int a = Math.max(i+1 - locations[i], 1);
8+
int b = Math.min(i+1 + locations[i], n);
9+
boolean A = false, B = false;
10+
if(min > a){
11+
min = a;
12+
A = true;
13+
}
14+
if(max < b){
15+
max = b;
16+
B = true;
17+
}
18+
if(A && B){
19+
count += 1;
20+
}
21+
}
22+
return count;
23+
}
24+
public static void main(String[] args){
25+
System.out.println(solution(3, new int[]{1,2,1}));
26+
}
27+
}
+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
def solution(dartResult):
2+
answer = 0
3+
4+
n = ''
5+
score = []
6+
for d in dartResult:
7+
if d.isnumeric():
8+
n += d
9+
elif d == 'S':
10+
n = int(n) ** 1
11+
score.append(n)
12+
n = ''
13+
elif d == 'D':
14+
n = int(n) ** 2
15+
score.append(n)
16+
n = ''
17+
elif d == 'T':
18+
n = int(n) ** 3
19+
score.append(n)
20+
n = ''
21+
elif d == '#':
22+
score[-1] = -score[-1]
23+
elif d == '*':
24+
if len(score) > 1:
25+
score[-1] = score[-1] * 2
26+
score[-2] = score[-2] * 2
27+
else:
28+
score[-1] = score[-1] * 2
29+
30+
return sum(score)
31+
32+
print(solution("1D2S#10S"))

Week6/공통/양궁대회/suhyun1.py

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
from itertools import combinations_with_replacement
2+
def solution(n, info):
3+
answer = [-1]
4+
max_gap = -1
5+
6+
for combi in combinations_with_replacement(range(11), n):
7+
info2 = [0] * 11
8+
9+
for c in combi:
10+
info2[10-c] += 1
11+
12+
a, l = 0, 0
13+
for i in range(11):
14+
if info[i] == info2[i] == 0:
15+
continue
16+
elif info[i] >= info2[i]:
17+
a += (10 - i)
18+
else:
19+
l += (10 - i)
20+
21+
if l > a:
22+
gap = l - a
23+
if gap > max_gap:
24+
max_gap = gap
25+
answer = info2
26+
27+
return answer
28+
29+
print(solution(5, [2,1,1,1,0,0,0,0,0,0,0]))

0 commit comments

Comments
 (0)