RosettaCodeData/Task/Largest-int-from-concatenated-ints/Python/largest-int-from-concatenated-ints-4.py
Ingy döt Net db842d013d A-M baby
2013-04-10 21:29:02 -07:00

6 lines
270 B
Python

from itertools import permutations
def maxnum(x):
return max(int(''.join(n) for n in permutations(str(i) for i in x)))
for numbers in [(1, 34, 3, 98, 9, 76, 45, 4), (54, 546, 548, 60)]:
print('Numbers: %r\n Largest integer: %15s' % (numbers, maxnum(numbers)))