File tree Expand file tree Collapse file tree 1 file changed +6
-5
lines changed
Expand file tree Collapse file tree 1 file changed +6
-5
lines changed Original file line number Diff line number Diff line change 1+ #!/usr/bin/python
2+ # -*- coding: utf-8 -*-
3+
14"""
25Source: https://www.instagram.com/p/CG7kv65A6s1/?utm_source=ig_web_copy_link
3-
46The following function accepts 2 positive integers
57and makes the first number as large as possible
68by swapping out its digits for digits in second number
7-
89>>> maximum_combination(9132,5564)
9109655
1011>>> maximum_combination(523,76)
@@ -26,17 +27,17 @@ def maximum_combination(first_num, second_num):
2627 second_num = [int (x ) for x in str (second_num )]
2728 first_num = [int (x ) for x in str (first_num )]
2829 second_num .sort (reverse = True )
29- for index , val in enumerate (first_num ):
30+ for ( index , val ) in enumerate (first_num ):
3031 if len (second_num ) > 0 :
3132 if second_num [0 ] > val :
3233 first_num [index ] = second_num [0 ]
3334 second_num .pop (0 )
3435 else :
3536 break
36- return int ("" .join (map (str , first_num )))
37+ return int ('' .join (map (str , first_num )))
3738
3839
39- if __name__ == " __main__" :
40+ if __name__ == ' __main__' :
4041 from doctest import testmod
4142
4243 testmod ()
You can’t perform that action at this time.
0 commit comments