diff options
Diffstat (limited to 'challenge-272/eric-cheung/python')
| -rwxr-xr-x | challenge-272/eric-cheung/python/ch-1.py | 7 | ||||
| -rwxr-xr-x | challenge-272/eric-cheung/python/ch-2.py | 9 |
2 files changed, 16 insertions, 0 deletions
diff --git a/challenge-272/eric-cheung/python/ch-1.py b/challenge-272/eric-cheung/python/ch-1.py new file mode 100755 index 0000000000..6ac6998ad4 --- /dev/null +++ b/challenge-272/eric-cheung/python/ch-1.py @@ -0,0 +1,7 @@ +
+## strIP = "1.1.1.1" ## Example 1
+strIP = "255.101.1.0" ## Example 2
+
+strOutput = strIP.replace(".", "[.]")
+
+print (strOutput)
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))
|
