13 September 2026
Chat Room Word Champion
Find who sent the highest share of long-word messages in a chat log.
You are given a chat log as a list of messages in the order they were sent. Each message names the username who sent it and its words, already split apart. A word counts as long when it has 5 or more characters. A message qualifies when it contains at least one long word. For each user, look at all of that user's messages. Find the fraction of their messages that qualify: their qualifying message count divided by their total message count. Return the username with the highest qualifying fraction. If two or more users are tied for the highest fraction, return whichever username comes first alphabetically.
Constraints
messages has between 1 and 500 entriesusername has between 1 and 20 lowercase letterseach message has between 0 and 30 wordseach word has between 1 and 20 lowercase letters
Function signature
def top_qualifying_fraction_user(messages):