diff options
Diffstat (limited to 'challenge-272/zapwai/python/ch-2.py')
| -rw-r--r-- | challenge-272/zapwai/python/ch-2.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/challenge-272/zapwai/python/ch-2.py b/challenge-272/zapwai/python/ch-2.py new file mode 100644 index 0000000000..4d488a2ab5 --- /dev/null +++ b/challenge-272/zapwai/python/ch-2.py @@ -0,0 +1,18 @@ +def proc(str): + chars = list(str) + num = [] + for c in chars: + num.append(ord(c)) + sum = 0 + for i in range(len(num) - 1): + sum += abs(num[i] - num[i + 1]) + print("Input:", str) + print("Output:", sum) + +str = "hello" +proc(str) +str = "perl" +proc(str) +str = "raku" +proc(str) + |
