add reverseind(s, i) function to convert indices in reverse(s) to indices in s