Skip to content

Commit

Permalink
2020-05-12-Alternating-Split-add-actual-code-for-passing-encrypt-meth…
Browse files Browse the repository at this point in the history
…od-test
  • Loading branch information
JinHoooooou committed May 12, 2020
1 parent 2721532 commit ea13812
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/alternatingSplit_20200512/Kata.java
Expand Up @@ -3,7 +3,19 @@
public class Kata {

public static String encrypt(final String text, final int n) {
return "";

String tempText = text;
String result = "";
for (int i = 0; i < n; i++) {
for (int j = 1; j < tempText.length(); j += 2) {
result += "" + tempText.charAt(j);
}
for (int j = 0; j < tempText.length(); j += 2) {
result += "" + tempText.charAt(j);
}
tempText = result;
}
return result;
}

public static String decrypt(final String encryptedText, final int n) {
Expand Down

0 comments on commit ea13812

Please sign in to comment.