We're actively looking for ideas on how to improve Weekly Challenges and would love to hear what you think!Submit Feedback
I am not entirely sure what the purpose of the exercise is since the expected results contain null values and have reversed visiting orders (e.g. user 2 and 4).
Here is my take on it, showing the actual relationship between stores visited.
I found this exercise confusing and unclear for a variety of reasons, including the solution that did not seem to properly address the stated task. It is unclear if the ordering of the transactions per customer is important or not, which in my opinion changes the problem and thus the solution. Given that, my solution looks very different, and is much less involved:
My solution leaves the mirrored/duplicated pairs rather than removing them, as I would the use of this output for the stated purpose analysis using the first merchant column as a dependent variable - otherwise, to find all the merchant pairs for a given merchant you would need to search in both columns.