Challenge question

After submitting the code only 3 cases were correct out of 4 …i want to know what was wrong in my code
import java.util.*;
public class Main {
public static void main(String args[]) {
// Your Code Here
Scanner scn = new Scanner(System.in);
String str = scn.nextLine();
StringBuilder sb = new StringBuilder(str);
int a=0;
int b =1;
int c = 1;
if(str.length()>=2 && str.length()<=1000)
{
for(int i =1;i<=str.length()-1;i++)
{
int as = ((int)(sb.charAt(b)))-((int)(sb.charAt(a)));
sb = sb.insert(c, as);
if(as>=0)
{
a = a+2;
b = b+2;
c = c+2;
}
else
{
a =a+3;
b =b+3;
c = c+3;
}
}
System.out.println(sb);
}
}
}
question:
Take as input S, a string. Write a program that inserts between each pair of characters the difference between their ascii codes and print the ans.

Input Format:
String

Constraints:
Length of String should be between 2 to 1000.

Output Format
String

Sample Input
acb
Sample Output
a2c-1b

Please share proper links to question and your code.
Save the code on ide and share its link so that it is easier to debug and find mistake in it.