diff options
| author | David Ferrone <zapwai@gmail.com> | 2024-09-23 11:56:29 -0400 |
|---|---|---|
| committer | David Ferrone <zapwai@gmail.com> | 2024-09-23 11:56:29 -0400 |
| commit | 2f5a634972c673db4d80141ce72c09b713b7200f (patch) | |
| tree | f85bd1a65172df7e83822fb740bd80eceb96574b /challenge-288/zapwai/python/ch-1.py | |
| parent | 5e8f04914943ac3a673d64d31ef0dfdec912a0bb (diff) | |
| download | perlweeklychallenge-club-2f5a634972c673db4d80141ce72c09b713b7200f.tar.gz perlweeklychallenge-club-2f5a634972c673db4d80141ce72c09b713b7200f.tar.bz2 perlweeklychallenge-club-2f5a634972c673db4d80141ce72c09b713b7200f.zip | |
Week 288
Diffstat (limited to 'challenge-288/zapwai/python/ch-1.py')
| -rw-r--r-- | challenge-288/zapwai/python/ch-1.py | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/challenge-288/zapwai/python/ch-1.py b/challenge-288/zapwai/python/ch-1.py new file mode 100644 index 0000000000..48ebd7985c --- /dev/null +++ b/challenge-288/zapwai/python/ch-1.py @@ -0,0 +1,29 @@ +def is_pal(s) : + r = str(s)[::-1] + return (str(s) == r) + +def proc(s) : + print("Input:", s) + n = int(s) + found = False + step = 1 + while not found : + m = n - step + if is_pal(m) : + found = True + n = m + else : + m = n + step + if is_pal(m) : + found = True + n = m + step += 1 + print("Output:", n) + +s = "123" +proc(s) +s = "2" +proc(s) +s = "1400" +proc(s) + |
