Skip to content

Commit aa21e22

Browse files
Merge pull request #753 from gmlrude/main
[박희경] 126차 라이브 코테 제출
2 parents df0da77 + aefbf51 commit aa21e22

File tree

2 files changed

+51
-0
lines changed

2 files changed

+51
-0
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
from itertools import *
2+
3+
def is_prime(num):
4+
if num < 2: return False
5+
for i in range(2, int(num**0.5) + 1):
6+
if num % i == 0: return False
7+
return True
8+
9+
def solution(numbers):
10+
answer = 0
11+
num_set = set()
12+
for i in range(1, len(numbers) + 1):
13+
for perm in permutations(numbers, i):
14+
num = int(''.join(perm))
15+
num_set.add(num)
16+
17+
for p in num_set:
18+
if is_prime(p):
19+
answer += 1
20+
21+
return answer
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
from collections import *
2+
3+
def solution(n, info):
4+
answer = []
5+
6+
q = deque()
7+
q.append((0, [0, 0, 0, 0, 0, 0, 0, 0, 0, 0])) # 현재 과녁, 상황
8+
max_gap = 0
9+
10+
while q:
11+
score, arrow = q.popleft()
12+
13+
if sum(arrow) == n:
14+
apeach, ryon = 0, 0
15+
for i in range(11):
16+
if info[i] != 0 or arrow[i] != 0:
17+
if info[i] >= arrow[i]:
18+
apeach += 10 - i
19+
else:
20+
ryon += 10 - i
21+
if apeach < ryon:
22+
gap = ryon - apeach
23+
if max_gap > gap:
24+
continue
25+
if max_gap < gap:
26+
max_gap = gap
27+
answer.clear
28+
answer.append(arrow)
29+
...
30+
return answer

0 commit comments

Comments
 (0)