Intermediate
Route a question, with a safe default
Write route(question, rules, default). rules is a list of (name, words, minimum) where words is a set. Count how many of a rule's words appear in the question (lower-cased words, each counted once).
Return the name of the rule with the highest count, but only if that count reaches its minimum and no other rule has the same highest count. In every other case return default.
What Check tests
- A clear winner above its minimum
- Below the minimum goes to the default
- No match goes to the default
- A tie goes to the default
- Case does not matter
Stuck? One hint at a time
The solution unlocks after your first Check. Try first: that is where the learning happens.
main.py
Sign in to run your code.
Output
Press Run to see what your program prints.