Created
November 9, 2021 09:00
-
-
Save matklad/77dd480b7b6e7d5eef93074b63b07391 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def print_all_sets(): | |
n = 3 | |
g = Gen() | |
while not g.done(): | |
print([g.gen(1) == 1 for _ in range(3)]) | |
class Gen: | |
def __init__(self): | |
self.v = [] | |
self.p = 0 | |
self.started = False | |
def done(self): | |
if not self.started: | |
self.started = True | |
return False | |
for i in reversed(range(len(self.v))): | |
if self.v[i][0] < self.v[i][1]: | |
self.v[i][0] += 1 | |
del self.v[i+1:] | |
self.p = 0 | |
return False | |
return True | |
def gen(self, bound): | |
if self.p == len(self.v): | |
self.v.append([0, 0]) | |
self.v[self.p][1] = bound | |
res = self.v[self.p][0] | |
self.p += 1 | |
return res | |
if __name__ == "__main__": | |
print_all_sets() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment