|  |  |  | @ -17,6 +17,21 @@ def probe(key, substrings, words): | 
			
		
	
		
			
				
					|  |  |  |  |     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): | 
			
		
	
		
			
				
					|  |  |  |  |     tree = {"": 0} | 
			
		
	
		
			
				
					|  |  |  |  |     while tree: | 
			
		
	
	
		
			
				
					|  |  |  | @ -26,6 +41,7 @@ def crack(substrings, words): | 
			
		
	
		
			
				
					|  |  |  |  |             return curr | 
			
		
	
		
			
				
					|  |  |  |  |         del tree[curr] | 
			
		
	
		
			
				
					|  |  |  |  |         tree.update(probe(curr, substrings, words)) | 
			
		
	
		
			
				
					|  |  |  |  |         remove_crap_from_list(tree, len(substrings[0]), 10) | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | if __name__ == "__main__": | 
			
		
	
	
		
			
				
					|  |  |  | 
 |