I'm trying to get all combinations of the following numbers as long as they don't total over 50,000 and must be in combos of 6. From there I want to condense into a new list that has no duplicates even if they're are out of order (ex: [8000, 9300, 7000, 8800, 7400, 9200] would be eliminated if [8800, 7400, 9200, 8000, 9300, 7000] was already in the list).
I think my code is correct but it is taking forever for the ouput to load in PyCharm. For now, I'm just looking to see if the len of the lists will be different to see if it is worth eliminating duplicates.
Sorry but I don't know how to get it to hold the indents when I post.
import itertools
num = {
9200, 8200, 7600, 9100, 7400, 8900, 7900,
7500, 7700, 6800, 9300, 9000, 7000, 8000,
8600, 7100, 8800, 7300, 8300, 8700, 8500,
9400, 6900, 7200
}
entry = []
for i in num:
for combination in itertools.combinations(num, 6):
if sum(combination) <= 50000:
entry.append(combination)
non_dup = []
for i in entry:
if i not in non_dup:
non_dup.append(i)
print("Entry list: " + str(len(entry)))
print("Non-Dup list: " + str(len(non_dup)))
I think my code is correct but it is taking forever for the ouput to load in PyCharm. For now, I'm just looking to see if the len of the lists will be different to see if it is worth eliminating duplicates.
Sorry but I don't know how to get it to hold the indents when I post.
import itertools
num = {
9200, 8200, 7600, 9100, 7400, 8900, 7900,
7500, 7700, 6800, 9300, 9000, 7000, 8000,
8600, 7100, 8800, 7300, 8300, 8700, 8500,
9400, 6900, 7200
}
entry = []
for i in num:
for combination in itertools.combinations(num, 6):
if sum(combination) <= 50000:
entry.append(combination)
non_dup = []
for i in entry:
if i not in non_dup:
non_dup.append(i)
print("Entry list: " + str(len(entry)))
print("Non-Dup list: " + str(len(non_dup)))