Hacker News new | ask | show | jobs
by ht85 875 days ago
Make it 3 times, you never know how clever those hackers folks could be!
1 comments

Make it infinite times and stop after the output stabilizes to a constant string!
I think this is actually a correct solution. Although not particularly elegant or efficient. If as long as if the string is unsafe the string will be modified. Then looping infinitely will never return an unsafe string. If it is also true that the modifications only delete characters then you will eventually arrive at a safe (or empty) string.