How to implement foo
function which works like this:
foo @ "abcdef"
"fdbace"
Steps: "bacdef", "cabdef", "dbacef", "ecabdf", "fdbace"
Reverse the first two letter of the string "abcdef"
which will give "bacdef"
. Then take this as the new string and reverse the first 3 letter. Similarly, proceed for all the characters of the string.