We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.

- All Contests
- ProjectEuler+
- Project Euler #145: How many reversible numbers are there below one-billion?
- Discussions

# Project Euler #145: How many reversible numbers are there below one-billion?

# Project Euler #145: How many reversible numbers are there below one-billion?

Contest ends in

#### Sort by

recency

#### |

#### 63 Discussions

#### |

Please Login in order to post a comment

Time Out Error

For those who are struggling solving this. At one time it took me about a week of work to solve this problem, may be longer. This is no way an easy thing, and I doubt the solution can be written as one function. Particularly, my solution contains near 600 lines and 17 helper functions.

Time out can anyone fix it

Facing timeout problem... !! def procedure(n): s=str(n) #print("s = ",s) s1 = s[::-1] if int(s1)>10: #print("s1 = ",s1) #print(int(s1)) s2=n+int(s1) #print("s2 = ",s2) if '2' not in str(s2) and '4' not in str(s2) and'6' not in str(s2) and'8' not in str(s2) and'0' not in str(s2): return True else: return Falset=int(input())#no of test cases while t>0: n=int(input()) c=0 for i in range(10,n): if procedure(i)==True: c=c+1

Time Complexity :--- O(no.of test cases* n).. Suggest me ...some alternatives.. !!

After many, many,

MANYattempts, I finally did it!