diff options
| author | Mohammad S Anwar <Mohammad.Anwar@yahoo.com> | 2021-11-04 20:17:52 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-11-04 20:17:52 +0000 |
| commit | e70b0509a48e09c26ee52ffca6e0ee4d33e696bf (patch) | |
| tree | b7eca790eb8d33933569df35b178284bac7f2627 /challenge-137/abigail/python/ch-2.py | |
| parent | 28d1be0c3868078f8ab1561d493a192c4c22d3ff (diff) | |
| parent | 896f286ee0b88f2a381b5a97cbbbd82bbf4712af (diff) | |
| download | perlweeklychallenge-club-e70b0509a48e09c26ee52ffca6e0ee4d33e696bf.tar.gz perlweeklychallenge-club-e70b0509a48e09c26ee52ffca6e0ee4d33e696bf.tar.bz2 perlweeklychallenge-club-e70b0509a48e09c26ee52ffca6e0ee4d33e696bf.zip | |
Merge pull request #5161 from Abigail/abigail/week-137
Abigail/week 137
Diffstat (limited to 'challenge-137/abigail/python/ch-2.py')
| -rw-r--r-- | challenge-137/abigail/python/ch-2.py | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/challenge-137/abigail/python/ch-2.py b/challenge-137/abigail/python/ch-2.py new file mode 100644 index 0000000000..8e27559fbf --- /dev/null +++ b/challenge-137/abigail/python/ch-2.py @@ -0,0 +1,29 @@ +#!/opt/local/bin/python + +# +# See ../README.md +# + +# +# Run as: python ch-2.py < input-file +# + +import fileinput + +def reverse (num): + rev = 0 + while num > 0: + rev = rev * 10 + (num % 10) + num = num // 10 + return rev + + +def ly (num): + if num >= 10000000: + return 1 + if num == reverse (num): + return 0 + return ly (num + reverse (num)) + +for number in fileinput . input (): + print (ly (int (number))) |
