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)

from toolset import iterate, quantify, take, memoize

def rev(n):
    """Return the reverse of n's digits"""
    return int(''.join(reversed(str(n))))

@memoize
def is_palindromic(n):
    return n == rev(n)

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

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

Simplify python solution to 55
Simplify python solution to 55

  from toolset import iterate, quantify, take, memoize
  
+ def rev(n):
+     """Return the reverse of n's digits"""
+     return int(''.join(reversed(str(n))))
- 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):
+ def is_palindromic(n):
-     return to_digits(num) == list(reversed(to_digits(num)))
+     return n == rev(n)
  
- def is_lychrel(num):
+ def is_lychrel(n):
-     rev = lambda x: to_num(reversed(to_digits(x)))
-     start = num + rev(num)
+     start = n + rev(n)
      iterations = iterate(lambda x: x + rev(x), start)
-     return not any(is_palindromic(n) for n in take(50, iterations))
+     return not any(is_palindromic(y) for y in take(50, iterations))
  
  def problem55():
      return quantify(range(1, 10000), pred=is_lychrel)
  
Simplify python solution to 55
## Code Before:
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)

## Instruction:
Simplify python solution to 55
## Code After:
from toolset import iterate, quantify, take, memoize

def rev(n):
    """Return the reverse of n's digits"""
    return int(''.join(reversed(str(n))))

@memoize
def is_palindromic(n):
    return n == rev(n)

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

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