aboutsummaryrefslogtreecommitdiff
path: root/challenge-137/abigail/python/ch-2.py
blob: 8e27559fbf25c9d5ca6778e9fede6eebb6c157ec (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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)))