Want to get involved? We're always looking for ideas and content for Weekly Challenges.
SUBMIT YOUR IDEAIt took me a while to wrap my head around the 'why' of this problem but it was a fun challenge!
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.