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

Para que se devuelva el numero maximo formado de los numeros dados:

Hay que convertir el numero es un cadena de strings y juntarlos en un array, ordenarlos de menor a mayor y luego invertir el orden, devolver el array ordenado de mayor a menor pasado a formato Long.

Code
Diff
  • import java.util.Arrays;
    
    class MaxNumber {
        public static long print(long number) {
            String stringDeNumber= Long.toString(number); //convierto la variable number de Long a String
            char[] arrayNumeros = stringDeNumber.toCharArray();  // creo un array a partir del string number
            Arrays.sort(arrayNumeros); //los ordeno de menos a mayor 
            StringBuilder numerosOrdenados = new StringBuilder(new String(arrayNumeros)).reverse(); // creo una variable tipo StringBuilder para cambiar el orden y que se acomoden de mayor a menor
            return Long.parseLong(numerosOrdenados.toString()); // paso la cadena ordenada de nuevo a Long
        }
    }
    
    //La notacion Big-O es: O(n log n) Tiempo lineal-logarítmico. Ya que usa ordenamientos y reordenamientos de strings 
    • import java.util.Arrays;
    • public class MaxNumber {
    • class MaxNumber {
    • public static long print(long number) {
    • return number
    • String stringDeNumber= Long.toString(number); //convierto la variable number de Long a String
    • char[] arrayNumeros = stringDeNumber.toCharArray(); // creo un array a partir del string number
    • Arrays.sort(arrayNumeros); //los ordeno de menos a mayor
    • StringBuilder numerosOrdenados = new StringBuilder(new String(arrayNumeros)).reverse(); // creo una variable tipo StringBuilder para cambiar el orden y que se acomoden de mayor a menor
    • return Long.parseLong(numerosOrdenados.toString()); // paso la cadena ordenada de nuevo a Long
    • }
    • }
    • }
    • //La notacion Big-O es: O(n log n) Tiempo lineal-logarítmico. Ya que usa ordenamientos y reordenamientos de strings
Code
Diff
  • module AreThereThree where
    
    solution :: Int -> Bool
    solution 0 = False
    solution x = y == 3 || solution x'
      where (x', y) = divMod (abs x) 10
    • module AreThereThree where
    • solution :: Int -> Bool
    • solution = go . abs
    • where
    • go 0 = False
    • go x = let (x', y) = x `divMod` 10 in y == 3 || go x'
    • solution 0 = False
    • solution x = y == 3 || solution x'
    • where (x', y) = divMod (abs x) 10
Strings
Code
Diff
  • isUnique = s => s.split("").filter((a,b,c) => c.indexOf(a) === b).length == s.length;
    
    • isUnique=s=>new Set(s).size==s.length
    • isUnique = s => s.split("").filter((a,b,c) => c.indexOf(a) === b).length == s.length;
Code
Diff
  • dumbRockPaperScissors
    
        =(a,b)=>
    
            a==b?`Draw`:`Player ${(a!={'Rock':'Paper','Paper':'Scissors','Scissors':'Rock'}[b])+1} wins`
    • function dumbRockPaperScissors(player1, player2) {
    • if (player1 === player2) return "Draw";
    • const condition = {
    • Scissors: "Paper",
    • Rock: "Scissors",
    • Paper: "Rock",
    • };
    • return player2 === condition[player1] ? "Player 1 wins" : "Player 2 wins";
    • }
    • dumbRockPaperScissors
    • =(a,b)=>
    • a==b?`Draw`:`Player ${(a!={'Rock':'Paper','Paper':'Scissors','Scissors':'Rock'}[b])+1} wins`
Algorithms
Arrays
Mathematics
Geometry