'''
Created on Mar 31, 2012

@author: mchrzanowski
'''

from time import time

def numberHasOnlyOddDigits(n):
    n = str(n)
    
    if '0' in n or  \
    '2' in n or     \
    '4' in n or     \
    '6' in n or     \
    '8' in n:
        return False
    
    return True

def main():
        
    reversibleNumbers = set()
        
    for i in xrange(1, 10 ** 8):
        
        if i in reversibleNumbers: continue
        
#        if numberHasOnlyOddDigits(i): continue

        if i % 10 == 0: continue
        
        reversedNumber = str(i)[::-1]
        
        result = i + int(reversedNumber)
        
        if numberHasOnlyOddDigits(result):
#            print i, reversedNumber, result
            reversibleNumbers.add(i)
            reversibleNumbers.add(int(reversedNumber))
    
    print "Solutions: ", len(reversibleNumbers)

if __name__ == '__main__':
    start = time()
    main()
    end = time()
    print 'Runtime:', end - start, 'seconds.'

@@ -362,63 +362,71 @@
 ** 8
+, 2
 ):
-%0A
      
-   %0A        if i in reversibleNumbers: continue
+# one of the two numbers must be odd. so skip even n.
 %0A   
@@ -430,26 +430,24 @@
         
-%0A#
         
 if numbe
@@ -442,47 +442,8 @@
     
-if numberHasOnlyOddDigits(i): continue%0A
 %0A   
@@ -506,16 +506,20 @@
 umber = 
+int(
 str(i)%5B:
@@ -522,16 +522,17 @@
 i)%5B::-1%5D
+)
 %0A       
@@ -536,50 +536,8 @@
     
-%0A        result = i + int(reversedNumber)%0A
     
@@ -579,38 +579,11 @@
 its(
-result):%0A#            print i,
+i +
  rev
@@ -597,16 +597,10 @@
 mber
-, result
+):
 %0A   
@@ -667,20 +667,16 @@
 ers.add(
-int(
 reversed
@@ -682,17 +682,16 @@
 dNumber)
-)
 %0A    %0A  

reduce runtime to 31 secs using pypy 1.8