the process should happen for each list
1…n in this case up to n = 17
@Tiago This is what I would have done:
Create a dictionary of all possible (sorted and joined) combinations as keys and assign your numbers as values
Sorting the list is the KEY to this solution so keep that in mind while working.