Pip -rS
, 7171 53 bytes
YRPg^sw:C`"\w+"`Wy~w.';.wY$`R$1$2.{IaNI@ZllPB[a0](lY@Zl@?a1)+:$2.$'RVSNbI+bNEb(ly0):{[_@1MS@_QaFIya]b}MUQ@Z V:yMUg^sRVSNl
I'm gonna golf this some more before writing a thorough explanation. The basic idea:
- Repr the input so it's one big string with the names areKeep a list of [name score] pairs in quotes but the numbers not
l
- Loop while there's a pair of names; replace every instancethrough the lines of input, split on spaces, using
MU
(for each line, the first name withitem isa
and the second name in everything before the pairitem isb
):- If
a
is not one of the names inl
, append[a 0]
tol
- Add
b
to the score inl
associated with the namea
(ifb
is a name, this adds 0*) - If
b
is not a number, change the namea
inl
tob
- If
- Eval to turnOnce the string back into a list again
- Do a bunch of mapping and filtering to extractloop is done, sort
l
in descending numerical order (since all the names are 0 in numeric context*, this sorts by the scores for each name; sort and print)
* Assuming that no names start with a digit, which I argue is the best Pip-specific interpretation of "whatever the input is, it won't be able to be parsed as a number."