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
Code
Diff
  • USING: ;
    IN: foo
    
    : bla ;
    • USING: ;
    • IN: foo
    • : bla ( -- ) 3 ;
    • : bla ;
Code
Diff
  • def multiply(a, b):
        return a*b
    • def multiply(a: int,b: int) -> int:
    • return (a*b)
    • def multiply(a, b):
    • return a*b
Code
Diff
  • def est_height(gender, dad_height, mom_height):
        return (dad_height+mom_height+1)/2 if gender == "boy" else (dad_height+mom_height-1)/2
    • import statistics
    • def est_height(gender, dad_height, mom_height):
    • avg = statistics.mean([dad_height, mom_height])
    • return avg + 0.5 if gender is "boy" else avg - 0.5
    • return (dad_height+mom_height+1)/2 if gender == "boy" else (dad_height+mom_height-1)/2
Fundamentals
Strings
Code
Diff
  • reverse_string = lambda n:n[::-1]
    • reverse_string = lambda n: n[::-1]
    • reverse_string = lambda n:n[::-1]
Puzzles

Prime Optimization

Code
Diff
  • import java.time.LocalDate;
    import java.time.format.DateTimeFormatter;
    import java.util.Arrays;
    
    public class PasswordValidation {
    
        private static final String TODAY_DATE = LocalDate.now().format(DateTimeFormatter.ofPattern("yyyyMMdd"));
        private static final String[] VALID_MONTHS = { "jan", "feb", "mar", "apr", "may", "jun", "jul", "aug", "sep", "oct", "nov", "dec" };
        private static final int[] PRIME = {23,29,31,37,41,43,47};
    
        public static boolean validatePassword(String password) {
            if (password.length() < 20 || password.length() > 50 || Arrays.binarySearch(PRIME, password.length()) < 0
            || !password.contains(String.valueOf(password.length())) || !password.contains(TODAY_DATE)
            || !Arrays.stream(VALID_MONTHS).anyMatch(s -> password.toLowerCase().contains(s)))
                return false;
            
            else if (!password.matches(("(.*[A-Z].*){3,}"))
                    || !password.matches("(.*[a-z].*){1,}")
                    || !password.matches("(.*[-._@#$&].*){1,}")
                    || password.matches(".*[-._@#$&][-._@#$&].*"))
                return false;
            
            else if (Arrays.stream(password.split("")).filter(s -> s.matches("[0-9]")).mapToInt(s -> Integer.valueOf(s)).sum() < 25)
                return false;
            
            else return true;
        }
    }
    
    • import java.time.LocalDate;
    • import java.time.format.DateTimeFormatter;
    • import java.util.Arrays;
    • public class PasswordValidation {
    • private static final String TODAY_DATE = LocalDate.now().format(DateTimeFormatter.ofPattern("yyyyMMdd"));
    • private static final String[] VALID_MONTHS = { "jan", "feb", "mar", "apr", "may", "jun", "jul", "aug", "sep", "oct",
    • "nov", "dec" };
    • private static final String[] VALID_MONTHS = { "jan", "feb", "mar", "apr", "may", "jun", "jul", "aug", "sep", "oct", "nov", "dec" };
    • private static final int[] PRIME = {23,29,31,37,41,43,47};
    • public static boolean validatePassword(String password) {
    • if (password.length() < 20 || password.length() > 50 || !isPrime(password.length())
    • if (password.length() < 20 || password.length() > 50 || Arrays.binarySearch(PRIME, password.length()) < 0
    • || !password.contains(String.valueOf(password.length())) || !password.contains(TODAY_DATE)
    • || !Arrays.stream(VALID_MONTHS).anyMatch(s -> password.toLowerCase().contains(s)))
    • return false;
    • else if (!password.matches(("(.*[A-Z].*){3,}"))
    • || !password.matches("(.*[a-z].*){1,}")
    • || !password.matches("(.*[-._@#$&].*){1,}")
    • || password.matches(".*[-._@#$&][-._@#$&].*"))
    • return false;
    • else if (Arrays.stream(password.split("")).filter(s -> s.matches("[0-9]")).mapToInt(s -> Integer.valueOf(s)).sum() < 25)
    • return false;
    • else return true;
    • }
    • public static boolean isPrime(int n) {
    • for (int i = 2; i <= Math.sqrt(n); i++) {
    • if (n % i == 0)
    • return false;
    • }
    • return true;
    • }
    • }