I have an array with strings.
Content: ["hello, my friend!", "hey bro you stupid friend", "im think you are good", "example is bad", "glad to see you"]
.
I want to construct a sentence randomly.
- Take a random offer from the array.
- Iterate through the entire array line by line and find a line in which there is a continuation from the word that ends the sentence from task No. 1. Fold them.
Example: random sentence = "hey bro you stupid friend"
. I want to get in the end: "hey bro you are good"
. (“hey bro you stupid friend” + “im think you are good”)
How can this be implemented for the purpose of random generation of proposals? There can be a maximum of 3000 elements in the array.