Участник:Polina Potapova/dota2-senate

Материал из DISCOPAL
Перейти к: навигация, поиск

https://leetcode.com/problems/dota2-senate/

class Solution(object):
    def predictPartyVictory(self, senate):
        """
        :type senate: str
        :rtype: str
        """
        count = 0
        while(len(set(senate)) > 1):
            tmp = ''
            for senator in senate:
                if senator == 'R':
                    if count >= 0:
                        tmp = tmp + 'R'
                    count += 1
                else:
                    if count <= 0:
                        tmp = tmp + 'D'
                    count -= 1
            senate = tmp
 
        if senate[0] == 'D':
            answer = 'Dire'
        else:
            answer = 'Radiant'
 
        return answer