W 개발 일지

온코더 레벨 12 대선 전략 수립 본문

카테고리 없음

온코더 레벨 12 대선 전략 수립

waVwe 2020. 11. 25. 20:49
반응형
class Solution:
    def solution(self, stats):
        self.s = stats
        self.t=[]
        for i in self.s:
            one=0
            two=0
            for j in i:
                if j == "1":
                    one+=1
                if j == "2":
                    two+=1
            res = one/(one+two)
            self.t.append(res)
        m = self.t.index(min(self.t))
        return m
cs

 

 

 

1과 2의 갯수를 세서 확률을 구한다.

가장 낮은 지역의 index가 필요함으로 index(min())를 이용한다

 

 

 

출처 : www.oncoder.com/

반응형