"""
problem55.py

If we take 47, reverse and add, 47 + 74 = 121, which is palindromic. A number
that never forms a palindrome through the reverse and add process is called a
Lychrel number. How many Lychrel numbers are there below ten-thousand? (Only
consider fifty iterations)
"""
from toolset import iterate, quantify, take, memoize

def to_digits(num):
    # to_digits(1234) --> [1, 2, 3, 4]
    return list(map(int, str(num)))

def to_num(digits):
    # to_num([1, 2, 3, 4]) --> 1234
    return int(''.join(map(str, digits)))

@memoize
def is_palindromic(num):
    return to_digits(num) == list(reversed(to_digits(num)))

def is_lychrel(num):
    rev = lambda x: to_num(reversed(to_digits(x)))
    start = num + rev(num)
    iterations = iterate(lambda x: x + rev(x), start)
    return not any(is_palindromic(n) for n in take(50, iterations))

def problem55():
    return quantify(range(1, 10000), pred=is_lychrel)

@@ -337,155 +337,58 @@
 def 
-to_digits(num):%0A    # to_digits(1234) --%3E %5B1, 2, 3, 4%5D%0A    return list(map(int, str(num)))%0A%0Adef to_num(digits):%0A    # to_num(%5B1, 2, 3, 4%5D) --%3E 1234
+rev(n):%0A    %22%22%22Return the reverse of n's digits%22%22%22
 %0A   
@@ -411,23 +411,23 @@
 oin(
-map(str, digits
+reversed(str(n)
 )))%0A
@@ -456,18 +456,16 @@
 dromic(n
-um
 ):%0A    r
@@ -474,55 +474,18 @@
 urn 
-to_digits(num) == list(reversed(to_digits(num))
+n == rev(n
 )%0A%0Ad
@@ -503,64 +503,11 @@
 el(n
-um
 ):%0A
-    rev = lambda x: to_num(reversed(to_digits(x)))%0A
     
@@ -519,18 +519,16 @@
  = n
-um
  + rev(n
 um)%0A
@@ -523,18 +523,16 @@
  + rev(n
-um
 )%0A    it
@@ -617,16 +617,16 @@
 mic(
-n
+y
 ) for 
-n
+y
  in 

Simplify python solution to 55