Given multiple sets of three items, how can I find the most-commonly occurring item among the sets using only one item from each set. The sets don't have duplicates, but if I'm thinking about this properly, it shouldn't matter.
Example: (1,2,3), (5,3,6), (4,3,7), (8,7,9), (5,1,8) I want to see which number is the most common if I can only pick one number from each set. So If I pick 3 from the first set, I can't use the 1 or the 2 in that set.
My guess is to make a ton of for loops and cycle through all the items in each set and generate an obscene number of tallies for the occurrences of each item and then compare them at the end, but this seems super inefficient, especially for larger sets and larger numbers of sets. So using this example, if I picked the first number of every set, the tally would look like this dictionary with item:#_of_occurrences, 1:1, 4:1, 5:2, 8:1 so since 5 occurred twice, it is the most common for this single tally. The problem is that I would need to do a ton more of them to actually compare all of the scenarios. The actual answer is that 3 is the most common number, and I'm looking for an efficient way to calculate something like that.