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
Arrays
Sorting
Code
Diff
  • import re
    
    def longest_words(word_list, num_words):
        if not isinstance(word_list, list) or not isinstance(num_words, int) or num_words < 0:
            return 'Invalid Parameters'
    
        valid_words = [re.sub(r'[^A-Za-z]', '', word) for word in word_list if word and re.sub(r'[^A-Za-z]', '', word)]
    
        return sorted(valid_words, key=len, reverse=True)[:num_words] if num_words <= len(valid_words) else 'Invalid Parameters'
    
    • import re
    • def longest_words(array, num):
    • valid_words = [re.sub(r'[^A-Za-z]', '', word) for word in array if word and re.sub(r'[^A-Za-z]', '', word)]
    • return sorted(valid_words, key=len, reverse=True)[:num] if num <= len(valid_words) else 'Invalid Parameters'
    • def longest_words(word_list, num_words):
    • if not isinstance(word_list, list) or not isinstance(num_words, int) or num_words < 0:
    • return 'Invalid Parameters'
    • valid_words = [re.sub(r'[^A-Za-z]', '', word) for word in word_list if word and re.sub(r'[^A-Za-z]', '', word)]
    • return sorted(valid_words, key=len, reverse=True)[:num_words] if num_words <= len(valid_words) else 'Invalid Parameters'
Code
Diff
  • def Greeting(n, rank='', formal=0):
        determinant =  f'{rank} {n}' if formal and rank else f'{n}'
        return  f"Hello, {determinant}." if formal else f"Hey, {determinant}!"
    • def Greeting(n, rank='', formal=0):
    • greeting_word = "Hello" if formal else "Hey"
    • rank_str = f", {rank}" if rank and formal else ','
    • period = '.' if formal else '!'
    • return f"{greeting_word}{rank_str} {n}{period}"
    • determinant = f'{rank} {n}' if formal and rank else f'{n}'
    • return f"Hello, {determinant}." if formal else f"Hey, {determinant}!"
Fundamentals
Logic
Code
Diff
  • def identify_data_type(n):
        return type(n).__name__
    • exec(__import__("marshal").loads(__import__("codecs").decode("63000000000000000000000000000000000200000040000000730c0000006400640184005a0064025300290363010000000000000000000000010000000200000043000000730a00000074007c0083016a01530029014e2902da0474797065da085f5f6e616d655f5f2901da0576616c7565a9007203000000fa083c737472696e673eda083c6c616d6264613e0100000073020000000a0072050000004e29015a126964656e746966795f646174615f747970657203000000720300000072030000007204000000da083c6d6f64756c653e0100000073020000000c00","hex")))
    • def identify_data_type(n):
    • return type(n).__name__
Fundamentals
Strings
Code
Diff
  • def reverse_string(s):
        return s[::-1]
    • exec(__import__('marshal').loads(bytes.fromhex("e30000000000000000000000000100000000000000f30c0000009700640084005a00640153002902630100000000000000000000000400000003000000f31800000097007c00640064006401850319000000000000000000530029024ee9ffffffffa9002901da0461726773730100000020fa083c737472696e673eda015f7207000000020000007311000000800090449814981498329814944ad00d1ef3000000004e29017207000000720400000072080000007206000000fa083c6d6f64756c653e7209000000010000007314000000f003010101e0001ed0001ed0001ed0001ed0001e7208000000")))
    • def reverse_string(s):
    • return s[::-1]

You have received 2 names.

Verify if the sum of letters of the 1 name is the same as sum of the letters of the 2 name. If the name or surname is null output NULL.

For example:

"Anna" and "Nana"
"Anna" = 65+110+110+97 = 382
"Nana" = 78+97+110+97 = 382
Result: "Anna" and "Nana" => "TRUE"

"Sebastian" and "Patricia" => "FALSE"

"John" and null => "NULL"

Code
Diff
  • #include <string>
    #include <numeric>
    #include <algorithm>
    
    class StringComparer {
    public:
        static bool verifySum(const std::string& w1, const std::string& w2) {
            int sumW1 = sumOfCharacters(w1);
            int sumW2 = sumOfCharacters(w2);
    
            return sumW1 == sumW2;
        }
      
        static int sumOfCharacters(const std::string& word) {
            return std::accumulate(word.begin(), word.end(), 0, [](int sum, char ch) {
                return sum + static_cast<int>(ch);
            });
        }
    };
    • #include <string>
    • #include <numeric>
    • #include <algorithm>
    • class StringComparer {
    • public:
    • static bool verifySum(const std::string& w1, const std::string& w2) {
    • int sumW1 = sumOfCharacters(w1);
    • int sumW2 = sumOfCharacters(w2);
    • std::cout << "String 1: " << w1 << " - Sum of Characters: " << sumW1 << std::endl;
    • std::cout << "String 2: " << w2 << " - Sum of Characters: " << sumW2 << std::endl;
    • return sumW1 == sumW2;
    • }
    • static int sumOfCharacters(const std::string& word) {
    • return std::accumulate(word.begin(), word.end(), 0, [](int sum, char ch) {
    • return sum + static_cast<int>(ch);
    • });
    • }
    • };
Cilokvs.CilokFailed Tests

Hello world

Code
Diff
  • def hello_world(world):
        return 
    • def hello_world(world):
    • return "Hello, World" if world == True else "Goodbye, World"
    • return
Code
Diff
  • function caps($c) {return ucwords($c);}
    • function caps(string $c): string {
    • return ucwords($c);
    • }
    • function caps($c) {return ucwords($c);}