Skip to content

Commit e750210

Browse files
yongjun-0903unknown
andauthored
[오늘의 알고리즘] 시소 짝꿍 (#64)
Co-authored-by: unknown <Administrator@SKCC20N00129.SKCC.NET>
1 parent 3e5d78a commit e750210

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

yongjun-0903/시소 짝꿍.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
from itertools import combinations
2+
from math import gcd
3+
4+
def solution(weights):
5+
answer = 0
6+
combs = list(combinations(weights, 2))
7+
siso = [2, 3, 4]
8+
9+
for comb in combs:
10+
if comb[0] == comb[1]:
11+
answer += 1
12+
else:
13+
x = gcd(comb[0], comb[1])
14+
if comb[0] // x and comb[1] // x in siso:
15+
answer += 1
16+
17+
return answer

0 commit comments

Comments
 (0)