aboutsummaryrefslogtreecommitdiff
path: root/challenge-217/eric-cheung/python/ch-2.py
blob: e1ea9d96d0bf0400c03d729fe665d7c46dfaf7c6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
from itertools import permutations

## arrList = [1, 23]  ## Example 1
## arrList = [10, 3, 2]  ## Example 2
## arrList = [31, 2, 4, 10]  ## Example 3
## arrList = [5, 11, 4, 1, 2]  ## Example 4
arrList = [1, 10]  ## Example 5

arrPerm = permutations(arrList)

nMax = 0

for arrLoop in arrPerm:
    strTempNum = "".join([str(nElemLoop) for nElemLoop in arrLoop])
    if int(strTempNum) > nMax:
        nMax = int(strTempNum)

print (nMax)