Quote:Original post by DevFredNope, you are right. My solution breaks down for strings with 3 non-consecutive differences. As with your tests, I only tried with 4 character strings, which don't cause it to break.
Looking forward to reading the solution :)
Unfortunately, it seems that ToohrVyk's solution also requires 2 characters of lookahead, and is complicated in Java, due to strings being constant.
As it stands, the most elegant way to solve this is by delegating the functionality to an inner function/closure, although there is potentially a deliciously evil way using an exception to signal the third case.