use python and regex
def find_lucky(text, num):
lucky = []
return sorted(lucky)
The function find_lucky parses/tokenizes text (see rules below)and returns a sorted list of words if the text is ‘lucky’ (seeabove definition).
The following rules apply to tokenize and classify words:
Use the re module to tokenize the text a token is a word thatcontains only letters or apostrophes
normalize the token to lower case
For example, if the parameter num is 7 then it returns an arrayof words ONLY if all the following conditions are true:
each word has 7 characters
each word occurs 7 times in the text
there are 7 of these words
Otherwise, return the empty list.
Solution
OR
OR