# 코딩 문제 관련/파이썬
[HackerRank - python] ACM ICPC Team
Hwiyong Jo
2022. 9. 7. 00:48
아래 블로그의 방법이 파이썬스럽고 깔끔해보인다.
https://velog.io/@jongmin97/hackerRank-ACM-ICPC-Team
[HackerRank] ACM ICPC Team
Hackerrank ACM ICPC Team 문제입니다. 난이도는 쉬움입니다.
velog.io
def acmTeam(topic):
# Write your code here
result = [0, 0]
for i in range(len(topic) - 1):
for j in range(i + 1, len(topic)):
sum_pair = str(int(topic[i]) + int(topic[j]))
count = sum_pair.count('1') + sum_pair.count('2')
if count > result[0]:
result[0] = count
result[1] = 1
elif count == result[0]:
result[1] += 1
return result