Leetcode 1006. Clumsy Factorial

class Solution(object):
    def clumsy(self, N):
        """
        :type N: int
        :rtype: int
        """
        op = {0: '*', 1: '//', 2: '+', 3: '-'}
        strN = list(map(str, range(N - 1, 0, -1)))
        ret = str(N)
        for i, s in enumerate(strN):
            ret += op[i % 4] + s
        return eval(ret)

 

posted @ 2019-03-30 07:00  周洋  阅读(172)  评论(0编辑  收藏  举报