Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

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

Sign up
Appearance settings

Commitfe1f4cc

Browse files
committed
Added command line argument usage and subset total.
1 parent48ed852 commitfe1f4cc

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
defmain():
48-
n=int(sys.argv[1])
49-
# n = 2
48+
if0<1<len(sys.argv):
49+
n=int(sys.argv[1])
50+
else:
51+
exit('Usage: subsets.py number')
5052

5153
globalsolutions
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)

[8]ページ先頭

©2009-2025 Movatter.jp