Triangle Quest 2

  • + 0 comments

    The logic is: For i=3 the numbers = [1,2,3,2,1] and enumerate([1,2,3,2,1]) = [(0,1), (1,2), (2,3), (3,2), (4,1)]. For each (index, value) : value * 10^(length-1-index) (0,1): 1 * 10^(5-1-0) = 1 * 10^4 = 10000 (1,2): 2 * 10^(5-1-1) = 2 * 10^3 = 2000
    (2,3): 3 * 10^(5-1-2) = 3 * 10^2 = 300 (3,2): 2 * 10^(5-1-3) = 2 * 10^1 = 20 (4,1): 1 * 10^(5-1-4) = 1 * 10^0 = 1 Sum: 10000 + 2000 + 300 + 20 + 1 = 12321 """