Count clusters of linked instruments
You have n instruments (labeled 0..n-1) and a list of links, where each link says two instruments belong to the same group. Links are transitive (if A links B and B links C, all three are one group). Count how many distinct groups exist.
n = 5, links = [(0,1), (1,2), (3,4)]
-> 2 # {0,1,2} and {3,4}
Return the number of connected groups.
Your answer
This one is open-ended. Work it through, then check your reasoning against the full solution.