Want to get involved? We're always looking for ideas and content for Weekly Challenges.
SUBMIT YOUR IDEAFollow simple logic: the combinations should not repeat. We are calculating combinations and not permutations. For each user ID, the distinct combinations are NC2 (combinations of 2). Note: consider NULL also as one entity.
I have provided the most fundamental solution for this problem.
Solved! The hardest part was keeping the null <-> non-null combos to get the same number of results as the solution has :)
Simple problem that broke my brain because I struggle to read sometimes, apparently... :)
My solution below, probably not the most elegant or dynamic approach: