Start a new Kumite
AllAgda (Beta)BF (Beta)CCFML (Beta)ClojureCOBOL (Beta)CoffeeScriptCommonLisp (Beta)CoqC++CrystalC#D (Beta)DartElixirElm (Beta)Erlang (Beta)Factor (Beta)Forth (Beta)Fortran (Beta)F#GoGroovyHaskellHaxe (Beta)Idris (Beta)JavaJavaScriptJulia (Beta)Kotlinλ Calculus (Beta)LeanLuaNASMNim (Beta)Objective-C (Beta)OCaml (Beta)Pascal (Beta)Perl (Beta)PHPPowerShell (Beta)Prolog (Beta)PureScript (Beta)PythonR (Beta)RacketRaku (Beta)Reason (Beta)RISC-V (Beta)RubyRustScalaShellSolidity (Beta)SQLSwiftTypeScriptVB (Beta)
Show only mine

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.

Ad
Ad
Strings

Cambio al inicializar el nextIndex

Code
Diff
  • 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);
    			}
    
    		}
    
    		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, int n) {
    • ArrayList<String> arr = new ArrayList<>();
    • StringBuilder strFinal = new StringBuilder(str);
    • for (int i = 0; i < str.length(); i++) {
    • int nextIndex = 0;
    • 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);
    • }
    • }
    • System.out.println(arr.toString());
    • String[] array = arr.toArray(new String[arr.size()]);
    • return array;
    • }
    • }
Strings
Code
Diff
  • //hacer que no funcione con una expresion regular con el caracter fin de cadena
    
    public class ConfusedDouble {
      
       public static String clearDouble(String str) {
    		if (str == null || str.length() == 0 || str.matches("^[^.]*$")){
          return ""; 
        } 
    		double num = Double.parseDouble(str.replaceAll("[^0-9.]", ""));
        String result = Double.toString(num);
        return result;
    	}
      
    }
     
    • //hacer que no funcione con una expresion regular con el caracter fin de cadena
    • public class ConfusedDouble {
    • public static String clearDouble(String str) {
    • if (str == null || str.length() == 0){
    • if (str == null || str.length() == 0 || str.matches("^[^.]*$")){
    • return "";
    • }
    • double num = Double.parseDouble(str.replaceAll("[^0-9.]", ""));
    • String result = Double.toString(num);
    • return result;
    • }
    • }
Fundamentals
Arrays