Skip to content

Commit e8d1450

Browse files
authored
Merge pull request #27 from zaqquum/main
Hongjoo/5์›” 2์ฃผ์ฐจ/4๋ฌธ์ œ
2 parents f430408 + 0def4e1 commit e8d1450

File tree

4 files changed

+81
-0
lines changed

4 files changed

+81
-0
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
from itertools import product
2+
def solution(word):
3+
answer = []
4+
li = ['A', 'E', 'I', 'O', 'U']
5+
for i in range(1,6):
6+
for per in product(li,repeat = i):
7+
answer.append(''.join(per))
8+
answer.sort()
9+
return answer.index(word)+1
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
from itertools import permutations
2+
def isPrime(n):
3+
if n <= 1 :
4+
return False
5+
6+
end = int(n**(1/2))
7+
for i in range(2,end+1):
8+
if n% i == 0 :
9+
return False
10+
return True
11+
12+
def solution(numbers):
13+
count = 0
14+
15+
arrnum= set() # ์ค‘๋ณต ๋ฐฉ์ง€
16+
#1. ๋ฌธ์ž์—ด ๋ถ„๋ฆฌํ•˜๊ธฐ -> ๋ฆฌ์ŠคํŠธ[] ์— ๋„ฃ๊ธฐ
17+
li = list(numbers)
18+
# ๋ถ„๋ฆฌ๋œ ์ˆซ์ž๋“ค์„ "์ˆœ์—ด ์กฐํ•ฉ"
19+
for i in range(1,len(numbers)+1) :
20+
p_arr =permutations(li,i)
21+
for perm in p_arr :
22+
num = int("".join(perm))
23+
arrnum.add(num)
24+
print( arrnum)
25+
#prime ํ™•์ธ
26+
for n in arrnum:
27+
if isPrime(n) :
28+
count+= 1
29+
return count
30+
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
def solution(brown, yellow):
2+
sum = brown + yellow
3+
# 1. w,h in [sum์˜ ์•ฝ์ˆ˜ ํ›„๋ณด๊ตฐ]
4+
m=2
5+
li = []
6+
while m <= sum :
7+
if sum % m == 0 :
8+
li.append(m)
9+
m += 1
10+
print(li)
11+
# 2. ์กฐ๊ฑด
12+
#2-1 w ๊ฐ€๋กœ >= h ์„ธ๋กœ
13+
#2-2 ๊ฐˆ์ƒ‰ = 2(w-1) + 2(h-1)
14+
#2-3 ๋…ธ๋ž€์ƒ‰ = (w-2) * (h-2)
15+
for w in li :
16+
for h in li:
17+
if w>=h and brown == (2*w+2*h-4) and yellow == ((w-2)*(h-2)) :
18+
answer = [w,h]
19+
return answer
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
from itertools import permutations
2+
3+
def solution(k, dungeons):
4+
# k : current_tired
5+
#1.์ˆœ์—ด -> ์ž…์žฅ ์ˆœ์„œ ๋ชจ๋“  ๊ฒฝ์šฐ์˜ ์ˆ˜
6+
dun_len= len(dungeons)
7+
order = permutations(dungeons , dun_len)
8+
answer = 0
9+
#2.์ž…์žฅ ๊ฐ€๋Šฅ ์—ฌ๋ถ€ ํ™•์ธ => ์ตœ๋Œ€ ๋˜์ „ ์ˆ˜ = answer ๋ฐ˜ํ™˜
10+
# k < ์ตœ์†Œ ํ•„์š” ํ”ผ๋กœ๋„ , break
11+
# ์ตœ์†Œ ํ•„์š” ํ”ผ๋กœ๋„ >= ์†Œ๋ชจ ํ”ผ๋กœ๋„
12+
for permute in order :
13+
hp = k
14+
count = 0
15+
for p in permute :
16+
17+
if hp >= p[0] :
18+
hp -=p[1]
19+
count += 1
20+
if count >answer :
21+
answer = count
22+
23+
return answer

0 commit comments

Comments
ย (0)