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.
Solución espacions en blanco
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) { ArrayList<String> arr = new ArrayList<>(); StringBuilder strFinal = new StringBuilder(str); for (int i = 0; i < str.length(); i++) { int nextIndex = (i + 1) % str.length(); // check white space if (str.charAt(i) != ' ' && str.charAt(nextIndex) != ' ') { nextIndex = (i + 1) % str.length(); strFinal.replace(i, i + 1, String.valueOf(str.charAt(nextIndex))); arr.add(strFinal.toString()); strFinal.replace(0, str.length(), str); } } System.out.println(arr.toString()); String[] array = arr.toArray(new String[arr.size()]); return array; } }
- 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) {
class Kata {public static String[] replaceLetter(String str) {ArrayList<String> arr = new ArrayList<>();- ArrayList<String> arr = new ArrayList<>();
- StringBuilder strFinal = new StringBuilder(str);
- for (int i = 0; i < str.length(); i++) {
- int nextIndex = (i + 1) % str.length();
if (str.charAt(i) != ' ') {//comprobar si i + 1 es un espacioint nextIndex = (i + 1) % str.length();- // check white space
- if (str.charAt(i) != ' ' && str.charAt(nextIndex) != ' ') {
- nextIndex = (i + 1) % str.length();
- strFinal.replace(i, i + 1, String.valueOf(str.charAt(nextIndex)));
- arr.add(strFinal.toString());
- strFinal.replace(0, str.length(), str);
- }
- }
// Convertimos ArrayList a ArrayString[] array = arr.toArray(new String[arr.size()]);return array;}}- System.out.println(arr.toString());
- String[] array = arr.toArray(new String[arr.size()]);
- return array;
- }
- }
class Solution{ public static int lastPoint(int fuel, int consumption, int[] stations) { if (fuel / consumption < stations[0]) { return -1; } int fuelLeft = fuel - stations[0] * consumption; for (int i = 1; i < stations.length; i++) { int distance = stations[i] - stations[i - 1]; if (fuelLeft > distance * consumption) { fuelLeft = fuelLeft - (distance * consumption); } else { return stations[i - 1]; } } return stations[stations.length - 1]; } }
- class Solution{
- public static int lastPoint(int fuel, int consumption, int[] stations) {
- if (fuel / consumption < stations[0]) {
- return -1;
- }
- int fuelLeft = fuel - stations[0] * consumption;
- for (int i = 1; i < stations.length; i++) {
- int distance = stations[i] - stations[i - 1];
fuelLeft = fuelLeft - distance * consumption;if (fuelLeft < 0) {- if (fuelLeft > distance * consumption) {
- fuelLeft = fuelLeft - (distance * consumption);
- }
- else {
- return stations[i - 1];
- }
- }
return -1;- return stations[stations.length - 1];
- }
- }
import java.util.HashMap; import java.util.Map; public class DiscoverTheValue{ public static int hello(String s) { Map<String, Integer> map = new HashMap<>(); int result = 0,num=1,letr=0; boolean correcto= false; for (int i = 0; i < 26; i++) { map.put(Character.toString('a' + i), i + 1); } // map.forEach((a,b)->System.out.println(a+"-"+b)); String numeros = "", letras = ""; for (int c = 0; c < s.length(); c++) { if (!String.valueOf(s.charAt(c)).equals(" ") && s.length()!=c+1) { if (String.valueOf(s.charAt(c)).matches("^\\d$")) { //numeros = numeros + s.charAt(c); correcto=true; num=num*s.charAt(c); } else if (String.valueOf(s.charAt(c)).matches("^[a-z]$")) { //letras = letras + s.charAt(c); } } else { correcto=false; numeros="";letras=""; } } System.out.println(numeros); System.out.println(letras); return result; } //Segunda opcion a considerar public static int discover(String valor) { if(valor.isEmpty()||valor.isBlank()) return 0; HashMap<String, Integer> values = new HashMap<>(); for(int i=0;i<26;i++) { values.put(Character.toString('a'+i), i+1); } boolean hasNumber = false; int score = 0, numberMultiplication = 1, characterSum = 0, stringPosition = 0; while(stringPosition<valor.length()) { boolean firstEmptySpace = true; while(String.valueOf(valor.charAt(stringPosition)).equals(" ") && stringPosition<valor.length()-1) { stringPosition++; if(firstEmptySpace) { firstEmptySpace = false; if(hasNumber)score+=Integer.compare(numberMultiplication, characterSum); else score--; } numberMultiplication =1; characterSum=0; hasNumber=false; } if(Character.isDigit(valor.charAt(stringPosition))) { numberMultiplication*=Character.getNumericValue(valor.charAt(stringPosition)); hasNumber = true; } else if(Character.isAlphabetic(valor.charAt(stringPosition))) characterSum+=values.get(String.valueOf(valor.charAt(stringPosition))); if(stringPosition==valor.length()-1) { if(hasNumber)score+=Integer.compare(numberMultiplication, characterSum); else score--; } stringPosition++; } return Integer.compare(score, 0); } }
public class pp{- import java.util.HashMap;
- import java.util.Map;
- public class DiscoverTheValue{
- public static int hello(String s) {
- Map<String, Integer> map = new HashMap<>();
- int result = 0,num=1,letr=0;
- boolean correcto= false;
- for (int i = 0; i < 26; i++) {
- map.put(Character.toString('a' + i), i + 1);
- }
- // map.forEach((a,b)->System.out.println(a+"-"+b));
- String numeros = "", letras = "";
- for (int c = 0; c < s.length(); c++) {
- if (!String.valueOf(s.charAt(c)).equals(" ") && s.length()!=c+1) {
- if (String.valueOf(s.charAt(c)).matches("^\\d$")) {
- //numeros = numeros + s.charAt(c);
- correcto=true;
- num=num*s.charAt(c);
- } else if (String.valueOf(s.charAt(c)).matches("^[a-z]$")) {
- //letras = letras + s.charAt(c);
- }
- } else {
- correcto=false;
- numeros="";letras="";
- }
- }
- System.out.println(numeros);
- System.out.println(letras);
- return result;
- }
- //Segunda opcion a considerar
- public static int discover(String valor) {
- if(valor.isEmpty()||valor.isBlank()) return 0;
- HashMap<String, Integer> values = new HashMap<>();
- for(int i=0;i<26;i++) {
- values.put(Character.toString('a'+i), i+1);
- }
- boolean hasNumber = false;
- int score = 0, numberMultiplication = 1, characterSum = 0, stringPosition = 0;
- while(stringPosition<valor.length()) {
- boolean firstEmptySpace = true;
- while(String.valueOf(valor.charAt(stringPosition)).equals(" ") && stringPosition<valor.length()-1) {
- stringPosition++;
- if(firstEmptySpace) {
- firstEmptySpace = false;
- if(hasNumber)score+=Integer.compare(numberMultiplication, characterSum);
- else score--;
- }
- numberMultiplication =1;
- characterSum=0;
- hasNumber=false;
- }
- if(Character.isDigit(valor.charAt(stringPosition))) {
- numberMultiplication*=Character.getNumericValue(valor.charAt(stringPosition));
- hasNumber = true;
- }
- else if(Character.isAlphabetic(valor.charAt(stringPosition))) characterSum+=values.get(String.valueOf(valor.charAt(stringPosition)));
- if(stringPosition==valor.length()-1) {
- if(hasNumber)score+=Integer.compare(numberMultiplication, characterSum);
- else score--;
- }
- stringPosition++;
- }
- return Integer.compare(score, 0);
- }
- }
import static org.junit.jupiter.api.Assertions.*; import java.util.HashMap; import org.junit.jupiter.api.RepeatedTest; import org.junit.jupiter.api.Test; class Tests { final String allChars = "abcdefghijklmnopqrstuvwxyz1234567890"; @Test void test() { assertEquals(1,DiscoverTheValue.discover("12345 98212")); assertEquals(1,DiscoverTheValue.discover("9999")); assertEquals(-1,DiscoverTheValue.discover("abcdefg")); assertEquals(-1,DiscoverTheValue.discover("zzzzzzz213 9ppppopppo2")); assertEquals(0,DiscoverTheValue.discover("abcdef 12345")); } @Test void hiddenTest() { assertEquals(0,DiscoverTheValue.discover("")); assertEquals(0,DiscoverTheValue.discover(" ")); assertEquals(0,DiscoverTheValue.discover("a1")); assertEquals(1,DiscoverTheValue.discover("a1b2c3 d4e5f6")); assertEquals(0,DiscoverTheValue.discover("a1b2c3 5y5")); assertEquals(0,DiscoverTheValue.discover("a1b2c3 5y5")); assertEquals(0,DiscoverTheValue.discover("5y5 a1b2c3")); assertEquals(1,DiscoverTheValue.discover("9%$@")); assertEquals(-1,DiscoverTheValue.discover("~$@#a")); } @RepeatedTest(100) void randomTests() { String randomString = generateRandomString(); assertEquals(discover(randomString),DiscoverTheValue.discover(randomString )); } private String generateRandomString() { StringBuilder randomString = new StringBuilder(); int finalStringLength =(int) (Math.random() * 100); for(int i=0;i<finalStringLength;i++) { int currentWordLength = (int) (Math.random() * 20); for(int j=0;j<currentWordLength;j++) { randomString.append(allChars.charAt((int)(Math.random() * 35))).append(" "); } } return randomString.toString().trim(); } public static int discover(String valor) { if(valor.isEmpty()||valor.isBlank()) return 0; HashMap<String, Integer> values = new HashMap<>(); for(int i=0;i<26;i++) { values.put(Character.toString('a'+i), i+1); } boolean hasNumber = false; int score = 0, numberMultiplication = 1, characterSum = 0, stringPosition = 0; while(stringPosition<valor.length()) { boolean firstEmptySpace = true; while(String.valueOf(valor.charAt(stringPosition)).equals(" ") && stringPosition<valor.length()-1) { stringPosition++; if(firstEmptySpace) { firstEmptySpace = false; if(hasNumber)score+=Integer.compare(numberMultiplication, characterSum); else score--; } numberMultiplication =1; characterSum=0; hasNumber=false; } if(Character.isDigit(valor.charAt(stringPosition))) { numberMultiplication*=Character.getNumericValue(valor.charAt(stringPosition)); hasNumber = true; } else if(Character.isAlphabetic(valor.charAt(stringPosition))) characterSum+=values.get(String.valueOf(valor.charAt(stringPosition))); if(stringPosition==valor.length()-1) { if(hasNumber)score+=Integer.compare(numberMultiplication, characterSum); else score--; } stringPosition++; } return Integer.compare(score, 0); } }
- import static org.junit.jupiter.api.Assertions.*;
- import java.util.HashMap;
- import org.junit.jupiter.api.RepeatedTest;
- 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 Tests {
class SolutionTest {@Testvoid testSomething() {// assertEquals("expected", "actual");}- final String allChars = "abcdefghijklmnopqrstuvwxyz1234567890";
- @Test
- void test() {
- assertEquals(1,DiscoverTheValue.discover("12345 98212"));
- assertEquals(1,DiscoverTheValue.discover("9999"));
- assertEquals(-1,DiscoverTheValue.discover("abcdefg"));
- assertEquals(-1,DiscoverTheValue.discover("zzzzzzz213 9ppppopppo2"));
- assertEquals(0,DiscoverTheValue.discover("abcdef 12345"));
- }
- @Test
- void hiddenTest() {
- assertEquals(0,DiscoverTheValue.discover(""));
- assertEquals(0,DiscoverTheValue.discover(" "));
- assertEquals(0,DiscoverTheValue.discover("a1"));
- assertEquals(1,DiscoverTheValue.discover("a1b2c3 d4e5f6"));
- assertEquals(0,DiscoverTheValue.discover("a1b2c3 5y5"));
- assertEquals(0,DiscoverTheValue.discover("a1b2c3 5y5"));
- assertEquals(0,DiscoverTheValue.discover("5y5 a1b2c3"));
- assertEquals(1,DiscoverTheValue.discover("9%$@"));
- assertEquals(-1,DiscoverTheValue.discover("~$@#a"));
- }
- @RepeatedTest(100)
- void randomTests() {
- String randomString = generateRandomString();
- assertEquals(discover(randomString),DiscoverTheValue.discover(randomString ));
- }
- private String generateRandomString() {
- StringBuilder randomString = new StringBuilder();
- int finalStringLength =(int) (Math.random() * 100);
- for(int i=0;i<finalStringLength;i++) {
- int currentWordLength = (int) (Math.random() * 20);
- for(int j=0;j<currentWordLength;j++) {
- randomString.append(allChars.charAt((int)(Math.random() * 35))).append(" ");
- }
- }
- return randomString.toString().trim();
- }
- public static int discover(String valor) {
- if(valor.isEmpty()||valor.isBlank()) return 0;
- HashMap<String, Integer> values = new HashMap<>();
- for(int i=0;i<26;i++) {
- values.put(Character.toString('a'+i), i+1);
- }
- boolean hasNumber = false;
- int score = 0, numberMultiplication = 1, characterSum = 0, stringPosition = 0;
- while(stringPosition<valor.length()) {
- boolean firstEmptySpace = true;
- while(String.valueOf(valor.charAt(stringPosition)).equals(" ") && stringPosition<valor.length()-1) {
- stringPosition++;
- if(firstEmptySpace) {
- firstEmptySpace = false;
- if(hasNumber)score+=Integer.compare(numberMultiplication, characterSum);
- else score--;
- }
- numberMultiplication =1;
- characterSum=0;
- hasNumber=false;
- }
- if(Character.isDigit(valor.charAt(stringPosition))) {
- numberMultiplication*=Character.getNumericValue(valor.charAt(stringPosition));
- hasNumber = true;
- }
- else if(Character.isAlphabetic(valor.charAt(stringPosition))) characterSum+=values.get(String.valueOf(valor.charAt(stringPosition)));
- if(stringPosition==valor.length()-1) {
- if(hasNumber)score+=Integer.compare(numberMultiplication, characterSum);
- else score--;
- }
- stringPosition++;
- }
- return Integer.compare(score, 0);
- }
- }
public class Encrypt { public static String encryptByVowels(String str) { String newS = ""; int cont = 0; for(char c: str.toLowerCase().toCharArray()) { if(c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u') cont++; } for(char c: str.toCharArray()) { int newChar = (int) c; if(c != ' '){ newChar = c+cont; if(newChar > 90 && newChar < 97) newChar+=(97-newChar); if(newChar > 122) { newChar = 64 + newChar%122; if(newChar > 90 && newChar < 97) newChar+=(97-newChar); } } newS+=""+(char)newChar; } return newS; } }
- public class Encrypt {
- public static String encryptByVowels(String str) {
return null;- String newS = "";
- int cont = 0;
- for(char c: str.toLowerCase().toCharArray()) {
- if(c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u')
- cont++;
- }
- for(char c: str.toCharArray()) {
- int newChar = (int) c;
- if(c != ' '){
- newChar = c+cont;
- if(newChar > 90 && newChar < 97)
- newChar+=(97-newChar);
- if(newChar > 122) {
- newChar = 64 + newChar%122;
- if(newChar > 90 && newChar < 97)
- newChar+=(97-newChar);
- }
- }
- newS+=""+(char)newChar;
- }
- return newS;
- }
- }
import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.assertEquals; import org.junit.jupiter.api.RepeatedTest; import org.junit.jupiter.api.DisplayName; import java.util.Random; // TODO: Replace examples and use TDD by writing your own tests class SolutionTest { @Test void testWords() { assertEquals("PR", Encrypt.encryptByVowels("PR")); assertEquals("bc", Encrypt.encryptByVowels("ab")); assertEquals("", Encrypt.encryptByVowels("")); } @Test void testWrap(){ assertEquals("ab", Encrypt.encryptByVowels("Za")); assertEquals("Ab", Encrypt.encryptByVowels("za")); } @Test void testEmptyOrBlank(){ assertEquals("", Encrypt.encryptByVowels("")); assertEquals(" ", Encrypt.encryptByVowels(" ")); } @Test void sentences(){ assertEquals("Mtqf vzj yfq", Encrypt.encryptByVowels("Hola que tal")); } @DisplayName("Random tests") @RepeatedTest(40) void randomTests() { Random rand = new Random(); String str = ""; for(int j = 0; j < rand.nextInt(1, 5); j++){ for(int i = 0; i < rand.nextInt(1, 100); i++){ int randomNumber = rand.nextInt(65, 122); if(randomNumber > 90 && randomNumber < 97) randomNumber+=(97-randomNumber); str+=""+(char)randomNumber; } str+=" "; } assertEquals(Encrypt.encryptByVowels(str.substring(0, str.length()-1)) ,sol(str.substring(0, str.length()-1))); } public static String sol(String str) { String newS = ""; int cont = 0; for(char c: str.toLowerCase().toCharArray()) { if(c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u') cont++; } for(char c: str.toCharArray()) { int newChar = (int) c; if(c != ' '){ newChar = c+cont; if(newChar > 90 && newChar < 97) newChar+=(97-newChar); if(newChar > 122) { newChar = 64 + newChar%122; if(newChar > 90 && newChar < 97) newChar+=(97-newChar); } } newS+=""+(char)newChar; } return newS; } }
- import org.junit.jupiter.api.Test;
- import static org.junit.jupiter.api.Assertions.assertEquals;
- import org.junit.jupiter.api.RepeatedTest;
- import org.junit.jupiter.api.DisplayName;
- import java.util.Random;
- // TODO: Replace examples and use TDD by writing your own tests
- class SolutionTest {
- @Test
void testSomething() {- void testWords() {
- assertEquals("PR", Encrypt.encryptByVowels("PR"));
- assertEquals("bc", Encrypt.encryptByVowels("ab"));
- assertEquals("", Encrypt.encryptByVowels(""));
- }
- @Test
- void testWrap(){
- assertEquals("ab", Encrypt.encryptByVowels("Za"));
- assertEquals("Ab", Encrypt.encryptByVowels("za"));
- }
- @Test
- void testEmptyOrBlank(){
- assertEquals("", Encrypt.encryptByVowels(""));
- assertEquals(" ", Encrypt.encryptByVowels(" "));
- }
- @Test
- void sentences(){
- assertEquals("Mtqf vzj yfq", Encrypt.encryptByVowels("Hola que tal"));
- }
- @DisplayName("Random tests")
- @RepeatedTest(40)
- void randomTests() {
- Random rand = new Random();
- String str = "";
for(int i = 0; i < rand.nextInt(1, 100); i++){int randomNumber = rand.nextInt(65, 122);if(randomNumber > 90 && randomNumber < 97)randomNumber+=(97-randomNumber);str+=""+(char)randomNumber;- for(int j = 0; j < rand.nextInt(1, 5); j++){
- for(int i = 0; i < rand.nextInt(1, 100); i++){
- int randomNumber = rand.nextInt(65, 122);
- if(randomNumber > 90 && randomNumber < 97)
- randomNumber+=(97-randomNumber);
- str+=""+(char)randomNumber;
- }
- str+=" ";
- }
assertEquals(Encrypt.encryptByVowels(str) ,sol(str));- assertEquals(Encrypt.encryptByVowels(str.substring(0, str.length()-1)) ,sol(str.substring(0, str.length()-1)));
- }
public static String sol(String s) {return s;- public static String sol(String str) {
- String newS = "";
- int cont = 0;
- for(char c: str.toLowerCase().toCharArray()) {
- if(c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u')
- cont++;
- }
- for(char c: str.toCharArray()) {
- int newChar = (int) c;
- if(c != ' '){
- newChar = c+cont;
- if(newChar > 90 && newChar < 97)
- newChar+=(97-newChar);
- if(newChar > 122) {
- newChar = 64 + newChar%122;
- if(newChar > 90 && newChar < 97)
- newChar+=(97-newChar);
- }
- }
- newS+=""+(char)newChar;
- }
- return newS;
- }
- }
//hacer que no funcione con una expresion regular con el caracter fin de cadena public class ConfusedDouble { public static double clearDouble(String str) { if (str == null || str.length() == 0) return 0; return Double.parseDouble(str.replaceAll("[^0-9.]", "")); } }
- //hacer que no funcione con una expresion regular con el caracter fin de cadena
public class Solution {- public class ConfusedDouble {
- public static double clearDouble(String str) {
- if (str == null || str.length() == 0) return 0;
- return Double.parseDouble(str.replaceAll("[^0-9.]", ""));
- }
- }
import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.assertEquals; class ConfusedDoubleTest { @Test void BasicTests() { // añadir tests de prueba, nulidad, cadena vacia etc // assertEquals("expected", "actual"); } }
- import org.junit.jupiter.api.Test;
- import static org.junit.jupiter.api.Assertions.assertEquals;
class SolutionTest {- class ConfusedDoubleTest {
- @Test
- void BasicTests() {
- // añadir tests de prueba, nulidad, cadena vacia etc
- // assertEquals("expected", "actual");
- }
- }
import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.assertEquals; class SolutionTest { @Test void basicTest() { assertEquals(4, Kumite.powerOfPrimes(123)); assertEquals(0, Kumite.powerOfPrimes(3476)); assertEquals(343, Kumite.powerOfPrimes(344338)); } @Test void onlyOdds() { assertEquals(130321, Kumite.powerOfPrimes(13537)); assertEquals(121, Kumite.powerOfPrimes(731)); assertEquals(-14, Kumite.powerOfPrimes(9311)); assertEquals(-4, Kumite.powerOfPrimes(13)); assertEquals(-50653, Kumite.powerOfPrimes(99757)); assertEquals(1, Kumite.powerOfPrimes(999)); } @Test void onlyEvens() { assertEquals(24, Kumite.powerOfPrimes(24648)); assertEquals(64, Kumite.powerOfPrimes(242)); assertEquals(1, Kumite.powerOfPrimes(888)); assertEquals(1, Kumite.powerOfPrimes(468)); assertEquals(5832, Kumite.powerOfPrimes(24822)); } @Test void negativeNumber() { assertEquals(0, Kumite.powerOfPrimes(-45)); assertEquals(0, Kumite.powerOfPrimes(-786)); assertEquals(0, Kumite.powerOfPrimes(-1)); } @Test void randomTests() { int max = 1000001; for (int i = 0; i < 1000000; i++) { int num = (int) (Math.random() * max); int expected = Kumite.powerOfPrimes(num); int actual = Kumite.powerOfPrimes(num); assertEquals(expected, actual); } } }
- import org.junit.jupiter.api.Test;
- import static org.junit.jupiter.api.Assertions.assertEquals;
- class SolutionTest {
- @Test
- void basicTest() {
- assertEquals(4, Kumite.powerOfPrimes(123));
assertEquals(0, Kumite.powerOfPrimes(-1));- assertEquals(0, Kumite.powerOfPrimes(3476));
- assertEquals(343, Kumite.powerOfPrimes(344338));
- }
- @Test
- void onlyOdds()
- {
- assertEquals(130321, Kumite.powerOfPrimes(13537));
- assertEquals(121, Kumite.powerOfPrimes(731));
- assertEquals(-14, Kumite.powerOfPrimes(9311));
- assertEquals(-4, Kumite.powerOfPrimes(13));
- assertEquals(-50653, Kumite.powerOfPrimes(99757));
- assertEquals(1, Kumite.powerOfPrimes(999));
- }
- @Test
- void onlyEvens()
- {
- assertEquals(24, Kumite.powerOfPrimes(24648));
- assertEquals(64, Kumite.powerOfPrimes(242));
- assertEquals(1, Kumite.powerOfPrimes(888));
- assertEquals(1, Kumite.powerOfPrimes(468));
- assertEquals(5832, Kumite.powerOfPrimes(24822));
- }
- @Test
- void negativeNumber()
- {
- assertEquals(0, Kumite.powerOfPrimes(-45));
- assertEquals(0, Kumite.powerOfPrimes(-786));
- assertEquals(0, Kumite.powerOfPrimes(-1));
- }
- @Test
- void randomTests() {
- int max = 1000001;
- for (int i = 0; i < 1000000; i++) {
- int num = (int) (Math.random() * max);
- int expected = Kumite.powerOfPrimes(num);
- int actual = Kumite.powerOfPrimes(num);
- assertEquals(expected, actual);
- }
- }
- }