Skip to content

Commit d9eb3ee

Browse files
Update maximum_combination.py
1 parent 670b77e commit d9eb3ee

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

maths/maximum_combination.py

+4-7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
#!/usr/bin/python
2-
# -*- coding: utf-8 -*-
3-
41
"""
52
Source: https://www.instagram.com/p/CG7kv65A6s1/?utm_source=ig_web_copy_link
63
The following function accepts 2 positive integers
@@ -19,25 +16,25 @@
1916
"""
2017

2118

22-
def maximum_combination(first_num, second_num):
19+
def maximum_combination(first_num, second_num) -> int:
2320
if first_num <= 0:
2421
return 0
2522
if second_num <= 0:
2623
return first_num
2724
second_num = [int(x) for x in str(second_num)]
2825
first_num = [int(x) for x in str(first_num)]
2926
second_num.sort(reverse=True)
30-
for (index, val) in enumerate(first_num):
27+
for index, val in enumerate(first_num):
3128
if len(second_num) > 0:
3229
if second_num[0] > val:
3330
first_num[index] = second_num[0]
3431
second_num.pop(0)
3532
else:
3633
break
37-
return int(''.join(map(str, first_num)))
34+
return int("".join(map(str, first_num)))
3835

3936

40-
if __name__ == '__main__':
37+
if __name__ == "__main__":
4138
from doctest import testmod
4239

4340
testmod()

0 commit comments

Comments
 (0)