Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- globguess=0
- def autosolver(solu,X):
- dashlen=len(solu)
- X=X+1
- word=""
- for dash in range(dashlen):
- word=word+"-"
- guess=0
- wrongletters=""
- modhangSolver(word,guess,solu,wrongletters,X)
- def modhangSolver(word,guess,solu,wrongletters,X):
- global globguess
- a=0
- b=0
- c=0
- d=0
- e=0
- f=0
- g=0
- h=0
- i=0
- j=0
- k=0
- l=0
- m=0
- n=0
- o=0
- p=0
- q=0
- r=0
- s=0
- t=0
- u=0
- v=0
- w=0
- x=0
- y=0
- z=0
- numA = 0
- numB = 0
- numC = 0
- numD = 0
- numE = 0
- numF = 0
- numG = 0
- numH = 0
- numI = 0
- numJ = 0
- numK = 0
- numL = 0
- numM = 0
- numN = 0
- numO = 0
- numP = 0
- numQ = 0
- numR = 0
- numS = 0
- numT = 0
- numU = 0
- numV = 0
- numW = 0
- numX = 0
- numY = 0
- numZ = 0
- sowpods=open("C:\Users\Tim K\Documents\sowpods.txt","r")
- wordlist=open("C:\Users\Tim K\Documents\Wordlist.txt","w")
- wordlist=open("C:\Users\Tim K\Documents\Wordlist.txt","r+")
- if word.count("-")==0:
- blob=0
- # print "word is already solved:", word
- # print "took", guess, "guesses"
- # print "guesses were", wrongletters
- return
- guess=guess+1
- word2=wrongletters
- hi=0
- for line in sowpods:
- testword=line
- hi=0
- if len(word)==len(testword)-1 :
- counter=-1
- for char in word:
- charl=char.lower()
- counter=counter+1
- if char != "-" and word.count(char)==testword.count(char) and testword[counter]==char:
- hi=hi+0
- if word.count(char,0,counter+1)==word.count(char):
- testword=testword.replace(char,charl)
- elif char =="-":
- hi=hi+0
- else:
- hi=hi+1
- for char in word2:
- if testword.count(char)!=0:
- hi=hi+1
- if hi==0:
- wordlist.write(testword)
- wordlist=open("C:\Users\Tim K\Documents\Wordlist.txt","r")
- for line in wordlist:
- testword2=line
- if testword2.count("A")>0:
- numA = numA + 1
- if testword2.count("B")>0:
- numB = numB + 1
- if testword2.count("C")>0:
- numC = numC + 1
- if testword2.count("D")>0:
- numD = numD + 1
- if testword2.count("E")>0:
- numE = numE + 1
- if testword2.count("F")>0:
- numF = numF + 1
- if testword2.count("G")>0:
- numG = numG + 1
- if testword2.count("H")>0:
- numH = numH + 1
- if testword2.count("I")>0:
- numI = numI + 1
- if testword2.count("J")>0:
- numJ = numJ + 1
- if testword2.count("K")>0:
- numK = numK + 1
- if testword2.count("L")>0:
- numL = numL + 1
- if testword2.count("M")>0:
- numM = numM + 1
- if testword2.count("N")>0:
- numN = numN + 1
- if testword2.count("O")>0:
- numO = numO + 1
- if testword2.count("P")>0:
- numP = numP + 1
- if testword2.count("Q")>0:
- numQ = numQ + 1
- if testword2.count("R")>0:
- numR = numR + 1
- if testword2.count("S")>0:
- numS = numS + 1
- if testword2.count("T")>0:
- numT = numT + 1
- if testword2.count("U")>0:
- numU = numU + 1
- if testword2.count("V")>0:
- numV = numV + 1
- if testword2.count("W")>0:
- numW = numW + 1
- if testword2.count("X")>0:
- numX = numX + 1
- if testword2.count("Y")>0:
- numY = numY + 1
- if testword2.count("Z")>0:
- numZ = numZ + 1
- ans = "none"
- cmax = 0
- if numA>cmax:
- ans = "A"
- cmax = numA
- if numB>cmax:
- ans = "B"
- cmax = numB
- if numC>cmax:
- ans = "C"
- cmax = numC
- if numD>cmax:
- ans = "D"
- cmax = numD
- if numE>cmax:
- ans = "E"
- cmax = numE
- if numF>cmax:
- ans = "F"
- cmax = numF
- if numG>cmax:
- ans = "G"
- cmax = numG
- if numH>cmax:
- ans = "H"
- cmax = numH
- if numI>cmax:
- ans = "I"
- cmax = numI
- if numJ>cmax:
- ans = "J"
- cmax = numJ
- if numK>cmax:
- ans = "K"
- cmax = numK
- if numL>cmax:
- ans = "L"
- cmax = numL
- if numM>cmax:
- ans = "M"
- cmax = numM
- if numN>cmax:
- ans = "N"
- cmax = numN
- if numO>cmax:
- ans = "O"
- cmax = numO
- if numP>cmax:
- ans = "P"
- cmax = numP
- if numQ>cmax:
- ans = "Q"
- cmax = numQ
- if numR>cmax:
- ans = "R"
- cmax = numR
- if numS>cmax:
- ans = "S"
- cmax = numS
- if numT>cmax:
- ans = "T"
- cmax = numT
- if numU>cmax:
- ans = "U"
- cmax = numU
- if numV>cmax:
- ans = "V"
- cmax = numV
- if numW>cmax:
- ans = "W"
- cmax = numW
- if numX>cmax:
- ans = "X"
- cmax = numX
- if numY>cmax:
- ans = "Y"
- cmax = numY
- if numZ>cmax:
- ans = "Z"
- cmax = numZ
- wrongletters=wrongletters+ans
- if ans == "none":
- print "FAILURE"
- return
- newword=""
- counter=-1
- for dash in solu:
- counter=counter+1
- if dash!=ans:
- newword=newword+word[counter]
- else:
- newword=newword+dash
- word=newword
- globguess=guess
- print guess
- if globguess==X:
- return
- modhangSolver(word,guess,solu,wrongletters,X)
- def autotester(X):
- wordlist2=open("C:\Users\Tim K\Documents\sowpods.txt","r")
- wordlistnew=open("C:\Users\Tim K\Documents\wordlist2.txt","w")
- iter=0
- for line in wordlist2:
- iter=iter+1
- line = line.strip()
- if len(line)>X:
- wordlistnew.write(line+"\n")
- else:
- autosolver(line,X)
- print iter
- if globguess>X:
- wordlistnew.write(line+"\n")
Add Comment
Please, Sign In to add comment