Given a string of 2 letters ab, your task is to convert it into ba.
You are allowed to add either aa or bb on either side of a current string or into the string, like ab=>abaa=>abbb=>aaabbb=>aaabaabb.
You are also allowed to erase either aa or bb any place like aaabbb=>abbb.
Is it possible? If so, how?
Unless my reasoning is wrong, the task is impossible.
There will always be an a somewhere to the left of a b.
Adding aa or bb cannot change this.
Removing aa or bb from the end cannot change this. You can't really remove the original b without first adding in a bb on its side. So you still have a b on the right side.
Removing aa or bb from the middle can only really remove an aa or bb that was previously added.
Posted by Jer
on 2019-01-17 12:10:50