Guest User

Untitled

a guest
Jun 13th, 2018
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.23 KB | None | 0 0
  1. globguess=0
  2.  
  3. def autosolver(solu,X):
  4. dashlen=len(solu)
  5. X=X+1
  6. word=""
  7. for dash in range(dashlen):
  8. word=word+"-"
  9. guess=0
  10. wrongletters=""
  11. modhangSolver(word,guess,solu,wrongletters,X)
  12.  
  13. def modhangSolver(word,guess,solu,wrongletters,X):
  14. global globguess
  15. a=0
  16. b=0
  17. c=0
  18. d=0
  19. e=0
  20. f=0
  21. g=0
  22. h=0
  23. i=0
  24. j=0
  25. k=0
  26. l=0
  27. m=0
  28. n=0
  29. o=0
  30. p=0
  31. q=0
  32. r=0
  33. s=0
  34. t=0
  35. u=0
  36. v=0
  37. w=0
  38. x=0
  39. y=0
  40. z=0
  41. numA = 0
  42. numB = 0
  43. numC = 0
  44. numD = 0
  45. numE = 0
  46. numF = 0
  47. numG = 0
  48. numH = 0
  49. numI = 0
  50. numJ = 0
  51. numK = 0
  52. numL = 0
  53. numM = 0
  54. numN = 0
  55. numO = 0
  56. numP = 0
  57. numQ = 0
  58. numR = 0
  59. numS = 0
  60. numT = 0
  61. numU = 0
  62. numV = 0
  63. numW = 0
  64. numX = 0
  65. numY = 0
  66. numZ = 0
  67. sowpods=open("C:\Users\Tim K\Documents\sowpods.txt","r")
  68. wordlist=open("C:\Users\Tim K\Documents\Wordlist.txt","w")
  69. wordlist=open("C:\Users\Tim K\Documents\Wordlist.txt","r+")
  70. if word.count("-")==0:
  71. blob=0
  72. # print "word is already solved:", word
  73. # print "took", guess, "guesses"
  74. # print "guesses were", wrongletters
  75. return
  76. guess=guess+1
  77. word2=wrongletters
  78. hi=0
  79. for line in sowpods:
  80. testword=line
  81. hi=0
  82. if len(word)==len(testword)-1 :
  83. counter=-1
  84. for char in word:
  85. charl=char.lower()
  86. counter=counter+1
  87. if char != "-" and word.count(char)==testword.count(char) and testword[counter]==char:
  88. hi=hi+0
  89. if word.count(char,0,counter+1)==word.count(char):
  90. testword=testword.replace(char,charl)
  91. elif char =="-":
  92. hi=hi+0
  93. else:
  94. hi=hi+1
  95. for char in word2:
  96. if testword.count(char)!=0:
  97. hi=hi+1
  98. if hi==0:
  99. wordlist.write(testword)
  100. wordlist=open("C:\Users\Tim K\Documents\Wordlist.txt","r")
  101. for line in wordlist:
  102. testword2=line
  103. if testword2.count("A")>0:
  104. numA = numA + 1
  105. if testword2.count("B")>0:
  106. numB = numB + 1
  107. if testword2.count("C")>0:
  108. numC = numC + 1
  109. if testword2.count("D")>0:
  110. numD = numD + 1
  111. if testword2.count("E")>0:
  112. numE = numE + 1
  113. if testword2.count("F")>0:
  114. numF = numF + 1
  115. if testword2.count("G")>0:
  116. numG = numG + 1
  117. if testword2.count("H")>0:
  118. numH = numH + 1
  119. if testword2.count("I")>0:
  120. numI = numI + 1
  121. if testword2.count("J")>0:
  122. numJ = numJ + 1
  123. if testword2.count("K")>0:
  124. numK = numK + 1
  125. if testword2.count("L")>0:
  126. numL = numL + 1
  127. if testword2.count("M")>0:
  128. numM = numM + 1
  129. if testword2.count("N")>0:
  130. numN = numN + 1
  131. if testword2.count("O")>0:
  132. numO = numO + 1
  133. if testword2.count("P")>0:
  134. numP = numP + 1
  135. if testword2.count("Q")>0:
  136. numQ = numQ + 1
  137. if testword2.count("R")>0:
  138. numR = numR + 1
  139. if testword2.count("S")>0:
  140. numS = numS + 1
  141. if testword2.count("T")>0:
  142. numT = numT + 1
  143. if testword2.count("U")>0:
  144. numU = numU + 1
  145. if testword2.count("V")>0:
  146. numV = numV + 1
  147. if testword2.count("W")>0:
  148. numW = numW + 1
  149. if testword2.count("X")>0:
  150. numX = numX + 1
  151. if testword2.count("Y")>0:
  152. numY = numY + 1
  153. if testword2.count("Z")>0:
  154. numZ = numZ + 1
  155. ans = "none"
  156. cmax = 0
  157. if numA>cmax:
  158. ans = "A"
  159. cmax = numA
  160. if numB>cmax:
  161. ans = "B"
  162. cmax = numB
  163. if numC>cmax:
  164. ans = "C"
  165. cmax = numC
  166. if numD>cmax:
  167. ans = "D"
  168. cmax = numD
  169. if numE>cmax:
  170. ans = "E"
  171. cmax = numE
  172. if numF>cmax:
  173. ans = "F"
  174. cmax = numF
  175. if numG>cmax:
  176. ans = "G"
  177. cmax = numG
  178. if numH>cmax:
  179. ans = "H"
  180. cmax = numH
  181. if numI>cmax:
  182. ans = "I"
  183. cmax = numI
  184. if numJ>cmax:
  185. ans = "J"
  186. cmax = numJ
  187. if numK>cmax:
  188. ans = "K"
  189. cmax = numK
  190. if numL>cmax:
  191. ans = "L"
  192. cmax = numL
  193. if numM>cmax:
  194. ans = "M"
  195. cmax = numM
  196. if numN>cmax:
  197. ans = "N"
  198. cmax = numN
  199. if numO>cmax:
  200. ans = "O"
  201. cmax = numO
  202. if numP>cmax:
  203. ans = "P"
  204. cmax = numP
  205. if numQ>cmax:
  206. ans = "Q"
  207. cmax = numQ
  208. if numR>cmax:
  209. ans = "R"
  210. cmax = numR
  211. if numS>cmax:
  212. ans = "S"
  213. cmax = numS
  214. if numT>cmax:
  215. ans = "T"
  216. cmax = numT
  217. if numU>cmax:
  218. ans = "U"
  219. cmax = numU
  220. if numV>cmax:
  221. ans = "V"
  222. cmax = numV
  223. if numW>cmax:
  224. ans = "W"
  225. cmax = numW
  226. if numX>cmax:
  227. ans = "X"
  228. cmax = numX
  229. if numY>cmax:
  230. ans = "Y"
  231. cmax = numY
  232. if numZ>cmax:
  233. ans = "Z"
  234. cmax = numZ
  235. wrongletters=wrongletters+ans
  236. if ans == "none":
  237. print "FAILURE"
  238. return
  239. newword=""
  240. counter=-1
  241. for dash in solu:
  242. counter=counter+1
  243. if dash!=ans:
  244. newword=newword+word[counter]
  245. else:
  246. newword=newword+dash
  247. word=newword
  248. globguess=guess
  249. print guess
  250. if globguess==X:
  251. return
  252. modhangSolver(word,guess,solu,wrongletters,X)
  253.  
  254. def autotester(X):
  255. wordlist2=open("C:\Users\Tim K\Documents\sowpods.txt","r")
  256. wordlistnew=open("C:\Users\Tim K\Documents\wordlist2.txt","w")
  257. iter=0
  258. for line in wordlist2:
  259. iter=iter+1
  260. line = line.strip()
  261. if len(line)>X:
  262. wordlistnew.write(line+"\n")
  263. else:
  264. autosolver(line,X)
  265. print iter
  266. if globguess>X:
  267. wordlistnew.write(line+"\n")
Add Comment
Please, Sign In to add comment