Very recently, I changed my SE username because I made this account some years ago and wanted to get back into asking questions. However, I’m still planning to post questions and potentially earn votes. We can imagine a site that has some issues dealing with name changes. The problem: given a list of names, reputation changes, and name changes, can you create a leaderboard of reputation? Assume everyone's reputation starts at 0.
Input comes in any reasonable format, and has two forms: a name change
<String, String> and a rep change
What does any reasonable format mean? When I write questions, it usually means the input can be rearranged or repackaged to work with the way your language takes in input (do you want a list of pairs? two lists? a string? that’s all fine) as long as it doesn’t add information or otherwise offload some of the computational work onto the human.
Name changes change a person’s username to any username not currently in use. For example, if A changes name to D, and B changes name to C, D (previously known as A) could still change their name to A or to B, even though these names have been used before. However, at any given moment the set of names are unique.
Rep changes represent something like getting up/down votes on a post, receiving a bounty, etc. All rep changes are guaranteed to be integers. They might come in the form <“Bob”, 5> or <“Alice”, -53000>. At the end, you must output all usernames that are currently in existence, and their rep counts, in descending order.
Alice 5 Bob 7 Bob John John 113 Alice Cheryl Daniel 13 John Alice Alice 12
Alice 132 Daniel 13 Cheryl 5
Test case, suggested by Unrelated String:
Jimmy Adam Donald 12 Amelia -11
Donald 12 Adam 0 Amelia -11
CodegoLfer65 12 Bluman 9 CodegoLfer65 n4me n4me -3
Bluman 9 n4me 9 (note: these two can be in either order)
Usernames are composed of only [A-Za-z0-9], i.e. alphanumerics. However, the input will not be a number in your language. This means usernames like
1e7 will not appear in the input. Numbers such as
2.8 do not appear due to the character specification in the first place.
This question seems heavy on data structures, so golfing languages may not perform as well. Maybe other languages will have a fighting chance? Scoring is by lowest number of bytes, i.e. tag:code-golf .