aboutsummaryrefslogtreecommitdiff
path: root/challenge-272/eric-cheung/python/ch-2.py
blob: 52f8329ed9e3f941abbf11c336f7634dfee8a55e (plain)
1
2
3
4
5
6
7
8
9
## strInput = "hello"  ## Example 1
## strInput = "perl"  ## Example 2
strInput = "raku"  ## Example 3

arrCode = [ord(charLoop) for charLoop in strInput]
arrCodeAbsDiff = [abs(arrCode[nIndx] - arrCode[nIndx + 1]) for nIndx in range(len(arrCode) - 1)]

print (sum(arrCodeAbsDiff))