Compare commits
2 Commits
88ca90b9d3
...
breakmono2
| Author | SHA1 | Date | |
|---|---|---|---|
| 6571c1dd2f | |||
| 139b78a417 |
@@ -17,6 +17,21 @@ def probe(key, substrings, words):
|
|||||||
return {key: val for key, val in key_hits.items() if val == best_val}
|
return {key: val for key, val in key_hits.items() if val == best_val}
|
||||||
|
|
||||||
|
|
||||||
|
def remove_crap_from_list(tree, max_depth, thr):
|
||||||
|
best = [-x * thr for x in range(max_depth+2)]
|
||||||
|
for key, val in tree.items():
|
||||||
|
if val > best[len(key)]:
|
||||||
|
best[len(key)] = val
|
||||||
|
|
||||||
|
import copy
|
||||||
|
tmp = copy.copy(list(tree.items()))
|
||||||
|
for key, val in tmp:
|
||||||
|
for i in range(len(key), max_depth+1):
|
||||||
|
if val < (best[i] - thr + (i-len(key))*thr*1.5):
|
||||||
|
del tree[key]
|
||||||
|
break
|
||||||
|
|
||||||
|
|
||||||
def crack(substrings, words):
|
def crack(substrings, words):
|
||||||
tree = {"": 0}
|
tree = {"": 0}
|
||||||
while tree:
|
while tree:
|
||||||
@@ -26,6 +41,7 @@ def crack(substrings, words):
|
|||||||
return curr
|
return curr
|
||||||
del tree[curr]
|
del tree[curr]
|
||||||
tree.update(probe(curr, substrings, words))
|
tree.update(probe(curr, substrings, words))
|
||||||
|
remove_crap_from_list(tree, len(substrings[0]), 10)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|||||||
Reference in New Issue
Block a user