Kumite (ko͞omiˌtā) is the practice of taking techniques learned from Kata and applying them through the act of freestyle sparring.
You can create a new kumite by providing some initial code and optionally some test cases. From there other warriors can spar with you, by enhancing, refactoring and translating your code. There is no limit to how many warriors you can spar with.
A great use for kumite is to begin an idea for a kata as one. You can collaborate with other code warriors until you have it right, then you can convert it to a kata.
Replace Letter
Given a string and a number (n), generate an array in which each position will be that same string but modifying the letter of its first position (0) by the one in its n position.
Input:
hello, 2
Output:
[lello, hollo, hehlo, heleo, helll]
Restrictions:
-
where n will always be a number between 0 and the length of the string.
-
It is case-insensitive and does not discriminate between letters, numbers, and special characters.
-
When current position + n is greater than the length of the string, it will return to start.
-
The spaces will be considered:
- If there is a space, that position will not be replaced.
- The space will not replace any letter.
For example
Given the string = "hello world"
and n=1
Should return:
[eello world, Hlllo world, Hello world, Heloo world, Hello oorld, Hello wrrld, Hello wolld, Hello wordd, Hello worlH]
It would not admit:
hellowword
hell word
import java.text.ParseException; import java.util.ArrayList; import java.util.Arrays; import java.util.Random; import java.util.concurrent.ThreadLocalRandom; public class Kata{ public static String[] replaceLetter(String str, int n) { ArrayList<String> arr = new ArrayList<>(); StringBuilder strFinal = new StringBuilder(str); for (int i = 0; i < str.length(); i++) { int nextIndex = (i + n) % str.length() ; if (str.charAt(i) != ' ' && str.charAt(nextIndex) != ' ') { nextIndex = (i + n) % str.length(); strFinal.replace(i, i + 1, String.valueOf(str.charAt(nextIndex))); arr.add(strFinal.toString()); strFinal.replace(0, str.length(), str); } } return arr.toArray(new String[arr.size()]); } }
- import java.text.ParseException;
- import java.util.ArrayList;
- import java.util.Arrays;
- import java.util.Random;
- import java.util.concurrent.ThreadLocalRandom;
- public class Kata{
- public static String[] replaceLetter(String str, int n) {
- ArrayList<String> arr = new ArrayList<>();
- StringBuilder strFinal = new StringBuilder(str);
- for (int i = 0; i < str.length(); i++) {
- int nextIndex = (i + n) % str.length() ;
- if (str.charAt(i) != ' ' && str.charAt(nextIndex) != ' ') {
- nextIndex = (i + n) % str.length();
- strFinal.replace(i, i + 1, String.valueOf(str.charAt(nextIndex)));
- arr.add(strFinal.toString());
- strFinal.replace(0, str.length(), str);
- }
- }
String[] array = arr.toArray(new String[arr.size()]);return array;- return arr.toArray(new String[arr.size()]);
- }
- }
import static org.junit.jupiter.api.Assertions.*; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.RepeatedTest; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; import java.util.Random; import java.util.ArrayList; // TODO: Replace examples and use TDD by writing your own tests class SolutionTest { @Test @Tag("BasicTest") void BasicTest() { String[] reverseLeterHello = { "lello", "hollo", "hehlo", "heleo", "helll" }; String[] reverseLeterBye = { "eye", "bbe", "byy" }; String[] reverseLeterCodewars = { "oello codewars", "hdllo codewars", "heelo codewars", "helwo codewars", "hella codewars", "hello sodewars", "hello chdewars", "hello coeewars", "hello codlwars", "hello codelars", "hello codewors", "hello codewarc" }; String[] reverseLeterThanks = { "Thanks", "Thanks", "Thanks", "Thanks", "Thanks", "Thanks" }; assertArrayEquals(reverseLeterHello, Kata.replaceLetter("hello", 3)); assertArrayEquals(reverseLeterBye, Kata.replaceLetter("bye", 2)); assertArrayEquals(reverseLeterCodewars, Kata.replaceLetter("hello codewars", 7)); assertArrayEquals(reverseLeterThanks, Kata.replaceLetter("Thanks", 0)); } @Test @Tag("SpecialCase") void SpecialCase() { String[] reverseLeterVoid = {}; assertArrayEquals(reverseLeterVoid, Kata.replaceLetter("", 2)); assertArrayEquals(reverseLeterVoid, Kata.replaceLetter(" ", 2)); assertArrayEquals(reverseLeterVoid, Kata.replaceLetter(" ", 0)); } @Tag("RandomTest") @RepeatedTest(10) @DisplayName("RandomWord") void RandomTest() { String word = generate(new Random().nextInt(15) + 1); int letterRandom = new Random().nextInt(word.length()); assertArrayEquals(replaceLetter(word, letterRandom), Kata.replaceLetter(word, letterRandom)); } public static String generate(int length) { String strChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890 ^*¨_:;=?¿"; StringBuilder sb = new StringBuilder(); for (int i = 0; i < length; i++) { int nRandom = new Random().nextInt(strChars.length()); sb.append(strChars.charAt(nRandom)); } return sb.toString(); } public static String[] replaceLetter(String str, int n) { ArrayList<String> arr = new ArrayList<>(); StringBuilder strFinal = new StringBuilder(str); for (int i = 0; i < str.length(); i++) { int nextIndex = (i + n) % str.length(); if (str.charAt(i) != ' ' && str.charAt(nextIndex) != ' ') { nextIndex = (i + n) % str.length(); strFinal.replace(i, i + 1, String.valueOf(str.charAt(nextIndex))); arr.add(strFinal.toString()); strFinal.replace(0, str.length(), str); } } String[] array = arr.toArray(new String[arr.size()]); return array; } }
- import static org.junit.jupiter.api.Assertions.*;
- import org.junit.jupiter.api.DisplayName;
- import org.junit.jupiter.api.RepeatedTest;
- import org.junit.jupiter.api.Tag;
- import org.junit.jupiter.api.Test;
- import java.util.Random;
- import java.util.ArrayList;
- // TODO: Replace examples and use TDD by writing your own tests
- class SolutionTest {
- @Test
- @Tag("BasicTest")
- void BasicTest() {
- String[] reverseLeterHello = { "lello", "hollo", "hehlo", "heleo", "helll" };
- String[] reverseLeterBye = { "eye", "bbe", "byy" };
- String[] reverseLeterCodewars = { "oello codewars", "hdllo codewars", "heelo codewars", "helwo codewars",
- "hella codewars", "hello sodewars", "hello chdewars", "hello coeewars", "hello codlwars",
- "hello codelars", "hello codewors", "hello codewarc" };
- String[] reverseLeterThanks = { "Thanks", "Thanks", "Thanks", "Thanks", "Thanks", "Thanks" };
- assertArrayEquals(reverseLeterHello, Kata.replaceLetter("hello", 3));
- assertArrayEquals(reverseLeterBye, Kata.replaceLetter("bye", 2));
- assertArrayEquals(reverseLeterCodewars, Kata.replaceLetter("hello codewars", 7));
- assertArrayEquals(reverseLeterThanks, Kata.replaceLetter("Thanks", 0));
- }
- @Test
- @Tag("SpecialCase")
- void SpecialCase() {
- String[] reverseLeterVoid = {};
- assertArrayEquals(reverseLeterVoid, Kata.replaceLetter("", 2));
- assertArrayEquals(reverseLeterVoid, Kata.replaceLetter(" ", 2));
- assertArrayEquals(reverseLeterVoid, Kata.replaceLetter(" ", 0));
- }
@Test@Tag("UnitTest")void parseExceptionFecha() {assertThrows(NullPointerException.class, () -> {int nRandom = new Random().nextInt(15)+1;Kata.replaceLetter(null, nRandom);});}- @Tag("RandomTest")
- @RepeatedTest(10)
- @DisplayName("RandomWord")
- void RandomTest() {
- String word = generate(new Random().nextInt(15) + 1);
- int letterRandom = new Random().nextInt(word.length());
- assertArrayEquals(replaceLetter(word, letterRandom), Kata.replaceLetter(word, letterRandom));
- }
- public static String generate(int length) {
String strChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";- String strChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890 ^*¨_:;=?¿";
- StringBuilder sb = new StringBuilder();
- for (int i = 0; i < length; i++) {
- int nRandom = new Random().nextInt(strChars.length());
- sb.append(strChars.charAt(nRandom));
- }
- return sb.toString();
- }
- public static String[] replaceLetter(String str, int n) {
- ArrayList<String> arr = new ArrayList<>();
- StringBuilder strFinal = new StringBuilder(str);
- for (int i = 0; i < str.length(); i++) {
- int nextIndex = (i + n) % str.length();
- if (str.charAt(i) != ' ' && str.charAt(nextIndex) != ' ') {
- nextIndex = (i + n) % str.length();
- strFinal.replace(i, i + 1, String.valueOf(str.charAt(nextIndex)));
- arr.add(strFinal.toString());
- strFinal.replace(0, str.length(), str);
- }
- }
- String[] array = arr.toArray(new String[arr.size()]);
- return array;
- }
- }
Given an array of strings and an array of ints, associate them from longest to shortest according to the length of each string. The output format must be a string with the syntax:
name1:number1,name2:number2,name3:number3... nameN:numberN
Input example:
String[]names = {"Ana", "Miguel", "Josemanuel"}
int[]numbers = {1034, 21, 537}
Output example:
"JoseManuel:1034,Miguel:537,Ana:21"
public class NamesAndNumbers{ public static String run(int[]numbers, String[] names){ if (numbers.length != names.length) { return "The size of the arrays are not the same"; } return ""; } }//end class.
- public class NamesAndNumbers{
- public static String run(int[]numbers, String[] names){
- if (numbers.length != names.length) {
- return "The size of the arrays are not the same";
- }
- return "";
- }
- }//end class.
import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.assertEquals; // TODO: Replace examples and use TDD by writing your own tests class SolutionTest { @Test void testLength() { String names[] = new String[] { "Ana", "Miguel", "Jose Manuel" }; int numbers[] = new int[] { 5, 20 }; assertEquals("The size of the arrays are not the same", NamesAndNumbers.run(numbers, names)); } }
- import org.junit.jupiter.api.Test;
- import static org.junit.jupiter.api.Assertions.assertEquals;
- // TODO: Replace examples and use TDD by writing your own tests
- class SolutionTest {
@Testvoid testSomething() {}- @Test
- void testLength() {
- String names[] = new String[] { "Ana", "Miguel", "Jose Manuel" };
- int numbers[] = new int[] { 5, 20 };
- assertEquals("The size of the arrays are not the same", NamesAndNumbers.run(numbers, names));
- }
- }
import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.assertEquals; import java.util.Random; import org.junit.jupiter.api.Tag; class ConfusedDoubleTest { @Test @Tag("SampleTests") void SampleTests() { //assertEquals("expected", "actual"); assertEquals("523.8822", ConfusedDouble.clearDouble("d5fjhjed`´<23.882fhhjk2")); assertEquals("3.15", ConfusedDouble.clearDouble("sakd3xH>Q;_r.wB1==5")); assertEquals("", ConfusedDouble.clearDouble("djasfkhkcnksnd12346gfkdj")); assertEquals("", ConfusedDouble.clearDouble("95847352414153884")); assertEquals("", ConfusedDouble.clearDouble("")); assertEquals("", ConfusedDouble.clearDouble(null)); } @Test @Tag("RandomTests") void randomTest() { //creates a string of 100 random characters from ASCII table Random r = new Random(); StringBuilder sb = new StringBuilder(); int i = 0; while(i < 100) { int numAscii = r.nextInt(256); if(numAscii != 46) {//46 - point in ASCII table sb.append((char)numAscii); i++; } } sb.insert(r.nextInt(sb.length()), '.'); String randomText = sb.toString(); assertEquals(Kata.clearDouble(randomText), ConfusedDouble.clearDouble(randomText)); } }
- import org.junit.jupiter.api.Test;
- import static org.junit.jupiter.api.Assertions.assertEquals;
- import java.util.Random;
- import org.junit.jupiter.api.Tag;
- class ConfusedDoubleTest {
- @Test
- @Tag("SampleTests")
- void SampleTests() {
- //assertEquals("expected", "actual");
- assertEquals("523.8822", ConfusedDouble.clearDouble("d5fjhjed`´<23.882fhhjk2"));
- assertEquals("3.15", ConfusedDouble.clearDouble("sakd3xH>Q;_r.wB1==5"));
- assertEquals("", ConfusedDouble.clearDouble("djasfkhkcnksnd12346gfkdj"));
- assertEquals("", ConfusedDouble.clearDouble("95847352414153884"));
- assertEquals("", ConfusedDouble.clearDouble(""));
- assertEquals("", ConfusedDouble.clearDouble(null));
- }
- @Test
- @Tag("RandomTests")
- void randomTest() {
- //creates a string of 100 random characters from ASCII table
- Random r = new Random();
- StringBuilder sb = new StringBuilder();
- int i = 0;
- while(i < 100) {
int numAscii = r.nextInt(256);if(numAscii != 46) {//46 - point in ASCII tablesb.append((char)numAscii);i++;}- int numAscii = r.nextInt(256);
- if(numAscii != 46) {//46 - point in ASCII table
- sb.append((char)numAscii);
- i++;
- }
- }
- sb.insert(r.nextInt(sb.length()), '.');
- String randomText = sb.toString();
- assertEquals(Kata.clearDouble(randomText), ConfusedDouble.clearDouble(randomText));
- }
- }
Added random test.
import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.assertEquals; import java.util.Arrays; import java.util.HashSet; import java.util.Random; // TODO: Replace examples and use TDD by writing your own tests class SolutionTest { @Test void basicTest() { assertEquals(10, Solution.lastPoint(52, 5, new int[] { 2, 5, 10, 15 })); assertEquals(45, Solution.lastPoint(250, 5, new int[] { 10, 15, 30, 45 })); assertEquals(-1, Solution.lastPoint(50, 25, new int[] { 10, 20, 30, 40, 50 })); } @Test void moreBasicTest() { assertEquals(16, Solution.lastPoint(100, 2, new int[] { 4, 8, 12, 16 })); assertEquals(20, Solution.lastPoint(130, 4, new int[] { 5, 15, 20, 50 })); assertEquals(-1, Solution.lastPoint(200, 10, new int[] { 80, 85, 100 })); } @Test void rareTest() { assertEquals(-1, Solution.lastPoint(0, 2, new int[] { 40, 80, 120, 160 })); assertEquals(160, Solution.lastPoint(100, 0, new int[] { 40, 80, 120, 160 })); assertEquals(0, Solution.lastPoint(200, 5, new int[] { 0, 0, 0, 0 })); assertEquals(5, Solution.lastPoint(200, 5, new int[] { 0, 0, 0, 5 })); } @Test void randomTest() { int fuel; int consumption; int[] stations; int[] values; for(int i = 0; i <= 100; i++) { values = randomNumbers(1000); fuel = values[0]; consumption = values[1]; stations = randomArray(50); int expected = getExpected(fuel, consumption, stations); assertEquals(expected, Solution.lastPoint(fuel, consumption, stations)); } } public static int[] randomNumbers(int valorMaximo) { Random random = new Random(); int[] numeros = new int[2]; do { numeros[0] = random.nextInt(valorMaximo + 1); numeros[1] = random.nextInt(valorMaximo + 1); } while (numeros[0] == numeros[1]); Arrays.sort(numeros); return numeros; } private static int[] randomArray(int max) { int n = Math.min(max, new Random().nextInt(100)); HashSet<Integer> districtsNumbers = new HashSet<>(); while (districtsNumbers.size() < n) { districtsNumbers.add(new Random().nextInt(max)); } int[] result = new int[n]; int i = 0; for (Integer value : districtsNumbers) result[i++] = value; Arrays.sort(result); return result; } public static int getExpected(int fuel, int consumption, int[] stations) { for (int station = stations.length -1; station >= 0; station--) { int difference = fuel - (consumption * stations[station]); if ( difference >= 0) { return stations[station]; } } return -1; } }
- import org.junit.jupiter.api.Test;
- import static org.junit.jupiter.api.Assertions.assertEquals;
- import java.util.Arrays;
- import java.util.HashSet;
- import java.util.Random;
- // TODO: Replace examples and use TDD by writing your own tests
- class SolutionTest {
- @Test
- void basicTest() {
- assertEquals(10, Solution.lastPoint(52, 5, new int[] { 2, 5, 10, 15 }));
- assertEquals(45, Solution.lastPoint(250, 5, new int[] { 10, 15, 30, 45 }));
- assertEquals(-1, Solution.lastPoint(50, 25, new int[] { 10, 20, 30, 40, 50 }));
- }
- @Test
- void moreBasicTest() {
- assertEquals(16, Solution.lastPoint(100, 2, new int[] { 4, 8, 12, 16 }));
- assertEquals(20, Solution.lastPoint(130, 4, new int[] { 5, 15, 20, 50 }));
- assertEquals(-1, Solution.lastPoint(200, 10, new int[] { 80, 85, 100 }));
- }
- @Test
- void rareTest() {
- assertEquals(-1, Solution.lastPoint(0, 2, new int[] { 40, 80, 120, 160 }));
- assertEquals(160, Solution.lastPoint(100, 0, new int[] { 40, 80, 120, 160 }));
- assertEquals(0, Solution.lastPoint(200, 5, new int[] { 0, 0, 0, 0 }));
- assertEquals(5, Solution.lastPoint(200, 5, new int[] { 0, 0, 0, 5 }));
- }
- @Test
void randomTest() {int fuel =0;int consumption =0;- void randomTest() {
- int fuel;
- int consumption;
- int[] stations;
- int[] values;
values = randomNumbers(200);for(int i = 0; i <= 20;i++){for(int valores : randomNumbers(200))fuel =values[0];consumption =values[1];}}- for(int i = 0; i <= 100; i++) {
- values = randomNumbers(1000);
- fuel = values[0];
- consumption = values[1];
- stations = randomArray(50);
- int expected = getExpected(fuel, consumption, stations);
- assertEquals(expected, Solution.lastPoint(fuel, consumption, stations));
- }
- }
- public static int[] randomNumbers(int valorMaximo) {
- Random random = new Random();
- int[] numeros = new int[2];
- do {
- numeros[0] = random.nextInt(valorMaximo + 1);
- numeros[1] = random.nextInt(valorMaximo + 1);
- } while (numeros[0] == numeros[1]);
- Arrays.sort(numeros);
- return numeros;
- }
- private static int[] randomArray(int max) {
- int n = Math.min(max, new Random().nextInt(100));
HashSet<Integer> distinctsNumbers = new HashSet<>();while (distinctsNumbers.size() < n) {distinctsNumbers.add(new Random().nextInt(max));- HashSet<Integer> districtsNumbers = new HashSet<>();
- while (districtsNumbers.size() < n) {
- districtsNumbers.add(new Random().nextInt(max));
- }
- int[] result = new int[n];
- int i = 0;
for (Integer value : distinctsNumbers)result[i++] = value;- for (Integer value : districtsNumbers) result[i++] = value;
- Arrays.sort(result);
- return result;
- }
- public static int getExpected(int fuel, int consumption, int[] stations) {
- for (int station = stations.length -1; station >= 0; station--) {
- int difference = fuel - (consumption * stations[station]);
- if ( difference >= 0) {
- return stations[station];
- }
- }
- return -1;
- }
- }
import java.util.*; import org.junit.Test; import static org.junit.Assert.assertEquals; import org.junit.runners.JUnit4; public class SolutionTest { public static String generarLetra() { StringBuilder phrase = new StringBuilder(); for (int i = 0; i < 1; i++) { char letter = (char) (new Random().nextInt('Z' - 'A') + 'A'); phrase.append(new Random().nextBoolean() ? letter : Character.toLowerCase(letter)); } return phrase.toString(); } public static String generator() { StringBuilder sb = new StringBuilder(); // Genera entre 1 y 10 letras aleatorias en mayúscula o minúscula int numLetters = new Random().nextInt(9) + 1; for (int i = 0; i < numLetters; i++) { sb.append(generarLetra()).append(" "); } // Añadir las letras y los números a la cadena en el formato letra número for (int i = 0; i < numLetters; i++) { int randomNums = new Random().nextInt(100) + 10; String nums = String.valueOf(randomNums); sb.append(nums); randomNums = new Random().nextInt(100) + 10; nums = String.valueOf(randomNums); sb.append(generarLetra()); sb.append(nums); if (i < numLetters - 1) sb.append(" "); } //Metemos todos los valores aleatorios en un ArrayList y desordenamos el patron ArrayList<String> list = new ArrayList<>(List.of(sb.toString().split(" "))); Collections.shuffle(list); StringBuilder result = new StringBuilder(); int i = 0; while (i < list.size() - 1) { result.append(list.get(i)); result.append(" "); i++; } result.append(list.get(i)); return result.toString(); } @Test public void sampleTests() { //Sample tests assertEquals("a:11a1 b:222b22 c:3c33", Kata.keyAlphabet("a b c 11a1 222b22 3c33")); assertEquals("a:11a1,222a33 b:222b22 c:3c33", Kata.keyAlphabet("222a33 a b c 11a1 222b22 3c33 5")); assertEquals("a:11a1,12a1,13a1 c:33c3 d:2d2", Kata.keyAlphabet("a d c x 11a1 2d2 33c3 13a1 12a1")); assertEquals("", Kata.keyAlphabet("")); assertEquals("a:11a1 b:2b2 c:33c3", Kata.keyAlphabet("a b c d 11a1 33c3 2b2")); assertEquals("a:11a1 b:2b2 c:33c3", Kata.keyAlphabet("a b c 11a1 33c3 2b2 d44")); //Tests assertEquals("a:a90,a90 b:12b6,33b4", Kata.keyAlphabet("a b c d e f g h i j k l m n o p q r s t u v w y z 33b4 5x5 12b6 A90 A90")); assertEquals("a:a11", Kata.keyAlphabet("a a a11")); } @Test public void randomTest(){ for(int i = 0; i < 5; i++){ String input = generator(); String expected = Kata.keyAlphabet(input); assertEquals(expected,Kata.keyAlphabet(input)); System.out.println(expected); } } }
- import java.util.*;
- import org.junit.Test;
- import static org.junit.Assert.assertEquals;
- import org.junit.runners.JUnit4;
- public class SolutionTest {
- public static String generarLetra() {
- StringBuilder phrase = new StringBuilder();
- for (int i = 0; i < 1; i++) {
- char letter = (char) (new Random().nextInt('Z' - 'A') + 'A');
- phrase.append(new Random().nextBoolean() ? letter : Character.toLowerCase(letter));
- }
- return phrase.toString();
- }
- public static String generator() {
- StringBuilder sb = new StringBuilder();
- // Genera entre 1 y 10 letras aleatorias en mayúscula o minúscula
- int numLetters = new Random().nextInt(9) + 1;
- for (int i = 0; i < numLetters; i++) {
- sb.append(generarLetra()).append(" ");
- }
- // Añadir las letras y los números a la cadena en el formato letra número
- for (int i = 0; i < numLetters; i++) {
- int randomNums = new Random().nextInt(100) + 10;
- String nums = String.valueOf(randomNums);
- sb.append(nums);
- randomNums = new Random().nextInt(100) + 10;
- nums = String.valueOf(randomNums);
- sb.append(generarLetra());
- sb.append(nums);
- if (i < numLetters - 1) sb.append(" ");
- }
- //Metemos todos los valores aleatorios en un ArrayList y desordenamos el patron
- ArrayList<String> list = new ArrayList<>(List.of(sb.toString().split(" ")));
- Collections.shuffle(list);
- StringBuilder result = new StringBuilder();
- int i = 0;
- while (i < list.size() - 1) {
- result.append(list.get(i));
- result.append(" ");
- i++;
- }
- result.append(list.get(i));
- return result.toString();
- }
- @Test
- public void sampleTests() {
- //Sample tests
- assertEquals("a:11a1 b:222b22 c:3c33", Kata.keyAlphabet("a b c 11a1 222b22 3c33"));
- assertEquals("a:11a1,222a33 b:222b22 c:3c33", Kata.keyAlphabet("222a33 a b c 11a1 222b22 3c33 5"));
- assertEquals("a:11a1,12a1,13a1 c:33c3 d:2d2", Kata.keyAlphabet("a d c x 11a1 2d2 33c3 13a1 12a1"));
- assertEquals("", Kata.keyAlphabet(""));
- assertEquals("a:11a1 b:2b2 c:33c3", Kata.keyAlphabet("a b c d 11a1 33c3 2b2"));
- assertEquals("a:11a1 b:2b2 c:33c3", Kata.keyAlphabet("a b c 11a1 33c3 2b2 d44"));
- //Tests
- assertEquals("a:a90,a90 b:12b6,33b4", Kata.keyAlphabet("a b c d e f g h i j k l m n o p q r s t u v w y z 33b4 5x5 12b6 A90 A90"));
- assertEquals("a:a11", Kata.keyAlphabet("a a a11"));
- }
- @Test
- public void randomTest(){
- for(int i = 0; i < 5; i++){
- String input = generator();
- String expected = Kata.keyAlphabet(input);
- assertEquals(expected,Kata.keyAlphabet(input));
- System.out.println(expected);
- }
- }
- }