Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
Well as the problem was just to return only one winner, I just evicted duplicates, which doesn't allow the other problem where you would want to return an ordered list of "winners" (?)
If that was the case, I would obviously choose another method to keep my results ordered (maybe an
OrderedDict
like you did)Sorry, I debuged with your source code.
I realized setdefault is only one saved in dictionary.
Yes. the other problem is exists.
Original problem: return first player
The other problem: return first, second player
How about?
In case
scores
only store the first candidate for each total score when iteratingcandidates
, which is ordered, and so the order is "preserved" as I evict all duplicates (look at thesetdefault
method usage)Maybe I shouldn't have used a dictionnary for this and just stored a
winner
variable updated when seeing a candidate with a better score, this would have been easier to read I think.How about equal player??
dictionary is not ordered.
scores is dictionary that not ordered.