def curious(x, primes): # First, check right truncation val = x for i in range(euler_util.length(x) - 1): val = rtrunc(val) if euler_util.bsearch(primes, val) == -1: return False # next, check left truncation val = x for i in range(euler_util.length(x) - 1): val = ltrunc(val) if euler_util.bsearch(primes, val) == -1: return False return True
def run(): count = 0 for p in range(1,22): for x in eu.numbers(1): l = eu.length(pow(x,p)) if l > p: break if l == p: count += 1 return count
def topheavy(num, den): return eu.length(num) > eu.length(den)