diff options
Diffstat (limited to 'challenge-272/eric-cheung/python/ch-2.py')
| -rwxr-xr-x | challenge-272/eric-cheung/python/ch-2.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/challenge-272/eric-cheung/python/ch-2.py b/challenge-272/eric-cheung/python/ch-2.py new file mode 100755 index 0000000000..52f8329ed9 --- /dev/null +++ b/challenge-272/eric-cheung/python/ch-2.py @@ -0,0 +1,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))
|
