from operator import mul def hexit(l): (c0,x)=(1,1) for p in l.keys(): e = l[p] c0 = c0 * p**(e%6) x = x * p**(e/6) return (c0,x) def facform(n): fac={} for r in range(2,n+1): e=0 while (n%r==0): print n,r e=e+1 n=n/r if (e!=0): fac[r]=e return fac def ffpow(ff, E): p={} for r in ff.keys(): p[r]=E*ff[r] return p import re f = open("candidates.txt","r") l = [g.strip("\n") for g in f] rr = [g.strip("\n") for g in open("../results2.txt","r")] for job in l: print job m = re.search('C([0-9]*)_([0-9]*)_([0-9]*)', job) d = m.group(1) x = int(m.group(2)) y = int(m.group(3)) N = x**y+y**x ss = [s for s in rr if s.startswith(str(x)+"^"+str(y))][0] factors = ss.split("=")[1].split("*") for v in factors: if (v[0] != "C"): pe = v.split("^") if (len(pe)==2): pe = int(pe[0])**int(pe[1]) else: pe = int(pe[0]) N=N/pe print N # start making the ggnfs input file snfs = ["n: "+str(N)] left = ffpow(facform(x),y) right = ffpow(facform(y),x) print [left,right] # remove common factors for g in left.keys(): if (g in right): print "FISH",g for pp in [(left,right),(right,left)]: (u,v)=pp for g in u.keys(): if (u[g]%6 > 3): more = 6 - u[g]%6 u[g] = u[g] + more if (g in v.keys()): v[g] = v[g] + more else: v[g] = more print "after step: ",left, right (c0,xx) = hexit(left) (c6,yy) = hexit(right) aside = ["c6: " + str(c6), "c0: " + str(c0)] rside = ["Y0: " + str(yy), "Y1: " + str(xx)] initial_params = ["lpbr: 31", "lpba: 31", "mfbr: 62", "mfba: 62", "alambda: 2.6", "rlambda: 2.6", "alim: 134217727", "rlim: 134217727"] snfs = snfs + ["skew: " + str(((c0+0.0)/(c6+0.0))**(1./6))] + aside + rside + initial_params oo = open(job+".initial_snfs","w") oo.write("\n".join(snfs)+"\n")