We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 48ed852 commit fe1f4ccCopy full SHA for fe1f4cc
1 file changed
backtracking/subsets.py
@@ -45,8 +45,10 @@ def backtrack_compact(working_set, k, n):
45
46
47
def main():
48
- n = int(sys.argv[1])
49
- # n = 2
+ if 0 < 1 < len(sys.argv):
+ n = int(sys.argv[1])
50
+ else:
51
+ exit('Usage: subsets.py number')
52
53
global solutions
54
solutions = []
@@ -56,6 +58,7 @@ def main():
56
58
57
59
backtrack_compact({}, 0, n)
60
print(solutions)
61
+ print('Number of subsets: {}'.format(len(solutions)))
62
63
64
if __name__ == '__main__':
0 commit comments