and the problem im having is subtracting the index before and after i from the string.

I agree with the group, to read 3 characters from your string at a time, then store them in past, current,...