Thirty answers to one question
Why it matters You cannot notice a default you have never seen laid out. Here are thirty of them, side by side.
The question: "Our product search endpoint takes 2 seconds. What would you change?" The starter holds thirty short answers like the ones an AI assistant, or a room of developers, typically gives. They were written for this lesson to show the pattern; they are illustrative, not a recording of any particular model.
Group them by approach and count. A family is a set of keywords: an answer belongs to the first family, in the order listed, whose keyword appears in its text.
approach_of("Put a Redis cache in front") # -> "cache"
approach_of("Profile it first") # -> "measure"
approach_of("Rewrite it in Rust") # -> "other"Recap The mode is the default. Look also at the small families: the rare answers are where the different ideas live.
Write approach_of(text): lowercase the text, then return the name of the first family in FAMILIES (in order) with any keyword that appears in it as a substring; "other" if none. Write group_by_approach(answers): a dict from family to the list of answer ids in it (only families that occur). Write mode(answers): the pair (family, count) for the most common family; on a tie, the one listed first in FAMILIES (and "other" after all of them). Finally set thirty_mode = mode(ANSWERS) and print the groups.
Spotted a problem in this lesson? Report it · Ask about this lesson
This exercise opens soon
Finish the lesson before it and this one unlocks. The whole course is free, no account needed, and you can read this lesson right now.
This browser is blocking cookies for learn.floati.life, so lessons you finished here cannot open in order. Allow cookies for this site and reload.