Let's have fun!
Given one or more paragraphs, and your job is to create an clean excerpt, subject to a maximum of 45 characters, including spaces. Then append an ellipsis (...) for the excerpt to make sense to the user.
For example, consider the following (please ignore the quote in this case):
"A set of words that is complete in itself, typically containing a subject and predicate, conveying a statement, question, exclamation, or command, and consisting of a main clause and sometimes one or more subordinate clauses."
An excerpt of 45 characters, including spaces:
"A set of words that is complete in itself, ty..."
The excerpt is good but we want the last word to be at least 3 characters long. That is, "typ" instead of "ty". It can be more than 3 characters though.
So, if that condition is not true, then we want to remove the last word ("ty") from the excerpt. In this case, we should have the following as excerpt:
"A set of words that is complete in itself,...".
As a bonus, you can also remove the comma, in this case to make thing even cleaner. Make sure your excerpt doesn't end with a comma before appending the ellipsis.
"A set of words that is complete in itself..."
How would you implement the above in your language. Sorry if the explanation is not clear. It's just for fun!