class OurPassword {
@Nested
class TestCases {
@Test
public void case1 () {
String s = "aukks";
String skip = "wbqd";
int index = 5;
String result = "happy";
// Assertions.assertEquals(result, solutionBack(s, skip, index));
Assertions.assertEquals(result, solution(s, skip, index));
}
@Test
public void case2 () {
String s = "abcde";
String skip = "";
int index = 0;
String result = "abcde";
// Assertions.assertEquals(result, solutionBack(s, skip, index));
Assertions.assertEquals(result, solution(s, skip, index));
}
@Test
public void case3 () {
String s = "abcde";
String skip = "";
int index = 1;
String result = "bcdef";
// Assertions.assertEquals(result, solutionBack(s, skip, index));
Assertions.assertEquals(result, solution(s, skip, index));
}
@Test
public void case4 () {
String s = "abcde";
String skip = "fghij";
int index = 5;
String result = "klmno";
// Assertions.assertEquals(result, solutionBack(s, skip, index));
Assertions.assertEquals(result, solution(s, skip, index));
}
@Test
public void case5 () {
String s = "ybc";
String skip = "az";
int index = 1;
String result = "bcd";
// Assertions.assertEquals(result, solutionBack(s, skip, index));
Assertions.assertEquals(result, solution(s, skip, index));
}
@Test
public void case6 () {
String s = "abd";
String skip = "";
int index = 2;
String result = "cdf";
// Assertions.assertEquals(result, solutionBack(s, skip, index));
Assertions.assertEquals(result, solution(s, skip, index));
}
@Test
public void case7 () {
String s = "xyz";
String skip = "";
int index = 2;
String result = "zab";
// Assertions.assertEquals(result, solutionBack(s, skip, index));
Assertions.assertEquals(result, solution(s, skip, index));
}
@Test
public void case8 () {
String s = "ace";
String skip = "d";
int index = 4;
String result = "fhi";
Assertions.assertEquals(result, solutionBack(s, skip, index));
// Assertions.assertEquals(result, solution(s, skip, index));
}
}
public String solution( String s, String skip, int index ){
StringBuilder builder = new StringBuilder();
for( int i = 0; i < s.length(); i ++) {
int charAt = s.charAt(i);
for (int j = 0; j < index; j ++) {
charAt ++;
if( charAt > 'z' ) charAt -= ('z'-'a'+1);
if( skip.contains(String.valueOf((char) charAt)) ) j --;
}
builder.append((char) charAt);
}
return builder.toString();
}
}