Censor Dispenser Challenge Doubt

So, I’m currently on Censor Dispenser Challenege and I’m stuck on negative words censor function. Most of the solutions shared uses that if two negative words have occurred, censor the rest of the negative word occurrences. But what if the text had two same negative words used one after the other. I mean that what if the first two negative word occurrences are of same word. I know this is not the case for the text given to us but I’m just trying to learn as much as I can through these challenges.

Welcome to the forums :slight_smile:

Try coming up with a model string that has those repeated negative words. What happens when you censor it? If it’s not what’s expected, what are some possible ways to tackle it?

hmm, will think about it. I just thought of way by making a counter function with the ability to return index after second occurrence and if it’s less than the .find index of second appearing negative word, i can assume the case i stated above. is this a good way

I’d be less concerned about the exact wording for this one and more about the functionality of the code you produce. If it does what you wanted it do and it completes the requirements then you’ve done it. Once completed you can always improve if you so wish.

If you want a challenge perhaps consider enabling a toggle e.g. repeats=TRUE/FALSE in the function call which either censors after ANY two negative words appear (including repeats) or censors only after two UNIQUE words from the censor list have been used (i.e. ignore repeats). The exact solution is up to you, write it, test it. Then you’ll have a pretty decent idea if it’s good or not. You’ll learn more and get practice either way.

1 Like

Thats a great idea. Thanks for that. I’ll surely try that