我需要一种更快的方法来生成列表的所有排列,然后检查每个排列是否在字典中。
for x in range (max_combo_len, 0, -1):
possible_combos = []
permutations = list(itertools.permutations(bag,x))
for item in permutations:
possible_combos.append(" ".join(item))
#then check to see if each possible combo is in a specific Dict
如果有帮助的话,列表都是字符串列表。['例如','这个','一']
我的解决方案有效,但速度很慢。可能我需要停止使用Python,但我想我应该先由您的专家来运行它!
最好的, 加里
目前没有回答
相关问题 更多 >
编程相关推荐