aboutsummaryrefslogtreecommitdiff
path: root/challenge-270/eric-cheung/python/ch-2.py
blob: fdd90ffe3d94d5817582649937adcacae3e4d4ff (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
nCost = 0

## Example 1
arrInt = [4, 1]
nX = 3
nY = 2

## Example 2
## arrInt = [2, 3, 3, 3, 5]
## nX = 2
## nY = 1

while len(set(arrInt)) > 1:
    arrInt = sorted(arrInt)
    
    if len(set(arrInt)) == 2 and arrInt.count(arrInt[0]) == 1:
        nCost = nCost + nX
    else:
        arrInt[1] = arrInt[1] + 1
        nCost = nCost + nY

    arrInt[0] = arrInt[0] + 1

print (nCost)