def expand(min, sum): if answers[min][sum] != -1: return answers[min][sum] if min > sum: answers[min][sum] = 0 return 0 if search.searchList(primes,sum): totals = 1 else: totals = 0 for i in xrange((sum-min)/2 + 1): if search.searchList(primes,min+i): totals += expand(min + i, sum - (min + i)) answers[min][sum] = totals return totals
def getFamily(n): digits = len(str(n)) family = [] original = n for i in xrange(0,10): tempFamily = [] n = str(original) tempOriginal = string.replace(n,str(i),"*") if string.count(tempOriginal,"*") == 3: for j in xrange(0,10): n = tempOriginal tempNum = int(string.replace(n,"*",str(j))) if search.searchList(primes,tempNum): tempFamily.append(tempNum) if (len(tempFamily) > len(family) or (len(tempFamily) != 0 and len(tempFamily) == len(family) and tempFamily[0] < family[0])) and len(str(tempFamily[0])) == digits: family = tempFamily return family
def findAnswer2(): combs = {} for a in primes: combs[a] = [] for b in primes: if ccatPrimes(a,b): combs[a].append(b) for i in combs: for j in combs[i]: for k in combs[j]: if search.searchList(combs[i],k): for l in combs[k]: if search.searchList(combs[i],l): if search.searchList(combs[j],l): for m in combs[l]: if search.searchList(combs[j],m): if search.searchList(combs[k],m): if search.searchList(combs[m],i): return i+j+k+l+m