Skip to content

Instantly share code, notes, and snippets.

@sleroy
Created March 4, 2020 12:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sleroy/a0717e94f1cf2c04e15106b75a532660 to your computer and use it in GitHub Desktop.
Save sleroy/a0717e94f1cf2c04e15106b75a532660 to your computer and use it in GitHub Desktop.
package ch.salt.code.challenge;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
public class CodeChallenge
{
public static String treatString(final String str) {
final int length = str.length();
final List<Character> charList = new ArrayList<Character>(str.length());
for (int zIndex = -1; zIndex < length - 1; ++zIndex) {
charList.add(str.charAt(zIndex + 1));
}
final List<Character> charList2 = new LinkedList<Character>();
int z2Index = -2;
final int value = 8;
final int res = value % 3;
while (z2Index < length - 2) {
charList2.add(charList2.size(), charList.get(z2Index + res));
z2Index++;
}
final char[] array = new char[length];
for (int i = 0; i < length; ++i) {
array[length - i - 1] = charList2.get(i);
}
return new String(array);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment