8000 Added command line argument usage and subset total. · buildm/practice-python@fe1f4cc · GitHub
[go: up one dir, main page]

Skip to content
Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit fe1f4cc

Browse files
committed
Added command line argument usage and subset total.
1 parent 48ed852 commit fe1f4cc

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

backtracking/subsets.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,10 @@ def backtrack_compact(working_set, k, n):
4545

4646

4747
def main():
48-
n = int(sys.argv[1])
49-
# n = 2
48+
if 0 < 1 < len(sys.argv):
49+
n = int(sys.argv[1])
50+
else:
51+
exit('Usage: subsets.py number')
5052

5153
global solutions
5254
solutions = []
@@ -56,6 +58,7 @@ def main():
5658

5759
backtrack_compact({}, 0, n)
5860
print(solutions)
61+
print('Number of subsets: {}'.format(len(solutions)))
5962

6063

6164
if __name__ == '__main__':

0 commit comments

Comments
 (0)
0