Ad
Code
Diff
  • def letter(str):
        mx = len(max(words, key=len)) if (words := [x for x in str.lower().strip().split() if x]) else 0
        starts = set(x[:i] for x in words for i in range(1, mx+1))
        return sorted(sum(sum([[matched for matched in [[word for word in words if word.startswith(s)]] if len(matched) == len(s)] for s in starts], []), []))
    • def letter(str):
    • result = []
    • words = [x for x in str.lower().strip().split() if x]
    • mx = len(max(words, key=len)) if words else 0
    • mx = len(max(words, key=len)) if (words := [x for x in str.lower().strip().split() if x]) else 0
    • starts = set(x[:i] for x in words for i in range(1, mx+1))
    • for s in starts:
    • matching = [word for word in words if word.startswith(s)]
    • if len(matching) == len(s):
    • result += matching
    • return sorted(result)
    • return sorted(sum(sum([[matched for matched in [[word for word in words if word.startswith(s)]] if len(matched) == len(s)] for s in starts], []), []))