aboutsummaryrefslogtreecommitdiff
path: root/challenge-163/eric-cheung/python/ch-2.py
blob: 478616180cd38102a44729482e57cad7eae78348 (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
## arrNum = [1, 2, 3, 4, 5] ## Example 1
arrNum = [1, 3, 5, 7, 9] ## Example 2

arrResult = []

for nRow in range(0, len(arrNum)):

    ## print (nRow)

    if (nRow == 0):
        arrResult = arrNum
        ## print (arrResult)
        continue

    arrTemp = arrResult
    arrResult = [arrTemp[1]]

    for nCol in range(2, len(arrTemp)):
        arrResult.append(arrResult[-1] + arrTemp[nCol])

    ## print (arrResult)
    

print (arrResult[0])