@@ -0,0 +1,1021 @@
+from itertools import combinations, cycle, islice%0Aclass Solution(object):%0A    def flipLights(self, n, m):%0A        %22%22%22%0A        :type n: int%0A        :type m: int%0A        :rtype: int%0A        %22%22%22%0A        if m %3E 4:%0A            return self.flipLights(n, 4 - m %25 2)%0A        if n %3E 6:%0A            return self.flipLights(6, m)%0A%0A        ans = set()%0A        for i in xrange(m %25 2, m + 1, 2):%0A            for comb in combinations(xrange(4), i):%0A                orig = %5BTrue%5D * n%0A                for flip in comb:%0A                    if flip == 0:%0A                        orig = %5Bnot x for x in orig%5D%0A                    elif flip == 1:%0A                        orig = %5Bnot x if i %25 2 == 0 else x for i, x in enumerate(orig)%5D%0A                    elif flip == 2:%0A                        orig = %5Bnot x if i %25 2 == 1 else x for i, x in enumerate(orig)%5D%0A                    elif flip == 3:%0A                        orig = %5Bnot x if i %25 3 == 0 else x for i, x in enumerate(orig)%5D%0A                ans.add(tuple(orig))%0A        return len(ans)%0A

Add py solution for 672. Bulb Switcher II