Level Log Token Hunt
Context
After a gaming session, a level log records lowercase words separated by spaces. Some words describe achievements, while others are too short to be useful. Build a helper for the score system that keeps every log word whose length reaches the chosen minimum, including repeated words and keeping their original order.
Problem
Given a log string and a minimum word length, return every complete word in the log whose length is at least the threshold. A word is a maximal consecutive sequence of lowercase letters, and spaces separate words. Preserve each qualifying occurrence in encounter order; do not merge repeated words or remove duplicates. If the log is empty or no word qualifies, return an empty string array.
Examples
log_text = "dark corridor opened slowly"minimum_length = 5["corridor", "opened", "slowly"]log_text = "echo echo lantern"minimum_length = 4["echo", "echo", "lantern"]log_text = "red dim fog"minimum_length = 4[]Constraints
0 <= len(log_text) <= 10001 <= minimum_length <= 1000log_text contains only lowercase letters and spaces.- Types:
log_textis str,minimum_lengthis int; result is str[]
Function signature
def qualifying_level_words(log_text: str, minimum_length: int) -> list[str]
log_textstr- The level log containing lowercase words separated by spaces.
minimum_lengthint- The smallest length a word may have to be included.
- returns list[str]
- All qualifying words, one entry per occurrence, in the same order as they appear in the log.
Adapted from MBPP problem task_7 (CC BY 4.0). Rewritten, extended and verified by Iksha.