File tree Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change
1
+ #!/usr/bin/env python3
2
+ import argparse
3
+
4
+ def run (args ):
5
+ num_trial = 0
6
+ for n100 in range (1 , args .total - 1 ):
7
+ n50_max = args .total - n100 - 1
8
+ assert n50_max >= 1
9
+ for n50 in range (1 , n50_max + 1 ):
10
+ n10 = args .total - n100 - n50
11
+ assert n10 >= 1
12
+ assert n100 + n50 + n10 == args .total
13
+ s = n100 * 100 + n50 * 50 + n10 * 10
14
+ num_trial += 1
15
+ if s == args .search_sum :
16
+ print (f'n100: { n100 } , n50: { n50 } , n10: { n10 } ' )
17
+ elif s > args .search_sum :
18
+ break
19
+
20
+ print (f'num_trial: { num_trial } ' )
21
+
22
+
23
+ def main ():
24
+ parser = argparse .ArgumentParser ()
25
+ parser .add_argument ('--total' , default = 45 )
26
+ parser .add_argument ('--search-sum' , default = 900 )
27
+ args = parser .parse_args ()
28
+
29
+ run (args )
30
+
31
+ if __name__ == '__main__' :
32
+ main ()
You can’t perform that action at this time.
0 commit comments