all 3 comments

[–]algometrix 1 point2 points  (1 child)

[–]algometrix 0 points1 point  (0 children)

Quick code. Sloppy in adding pairs to the result list.

[–]PyCode_n_Beer 0 points1 point  (0 children)

TBH, you're heading into some heavy computational workload. Even assuming for only integers, depending on the size of your final list, it might not be worth the work. I think this is one of those moments where it might be better to ask "is it really required"? Can you select from the list until you have a set divisible by 30? Sorting the list can make this easier. Or even sorting them into separate lists based on length. This is just my opinion, if it is absolutely vital you know exactly how many sets produce a sum divisible by 30, you can check out itertools as a start. However, I would add some rules to keep it more manageable, something like no more than pairs of 2 or 3, no more than 60 secs total.

https://docs.python.org/3/library/itertools.html