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
  • #define add std::plus<>()
    • template<typename T>
    • T add(const T& a, const T &b){
    • return std::plus<T>()(a, b);
    • }
    • #define add std::plus<>()
Code
Diff
  • def mul():
        sum=0
        for i in range(1, 1000):
            if(i % 3 == 0 or i % 5 == 0):
                sum += i
        return sum
        
    • def mul():
    • sum=0
    • for i in range(1001):
    • if i>0:
    • if(i%3==0 or i%5==0):
    • sum=sum+1
    • return sum
    • for i in range(1, 1000):
    • if(i % 3 == 0 or i % 5 == 0):
    • sum += i
    • return sum
Arrays
Data Types
Code
Diff
  • function func(N, point) {
      return funcHelper(N, point, [])
    }
    
    function funcHelper(N, x, arr) {
      return N === 0 ? arr : funcHelper(N - 1, x - 1, [...arr, Math.abs(x)])
    }
    • function func(N, point) {
    • let start = 0; // starting position of array
    • let clonePoint = point; // clone for point to start counting from that number at begining of array
    • let arr = [...Array(N).keys()] // generate array and fill with 0 to 10
    • if(!(point > N)) {
    • arr.forEach((o, index) => {
    • index < point ? arr[index] = clonePoint-- : arr[index] = start++;
    • });
    • return arr;
    • }
    • return [];
    • return funcHelper(N, point, [])
    • }
    • function funcHelper(N, x, arr) {
    • return N === 0 ? arr : funcHelper(N - 1, x - 1, [...arr, Math.abs(x)])
    • }
Mathematics
Algorithms
Logic
Numbers

PEP 8 - Naming Conventions - Function Names:

Function names should be lowercase, with words separated by underscores as necessary to improve readability.

This naming style is commonly known as snake_case.

Furthermore, the variable assignment in the previous Kumite is not required; the computed result can be returned immediately.

Finally, as per the Python Test Reference in the official Codewars Docs, the order of arguments for Test.assert_equals should be actual, expected instead of the other way round.

Code
Diff
  • from itertools import permutations
    def sequence_permutation(t, n):
        return list(permutations(t, n))
    • from itertools import permutations
    • def SequencePermutation(plenty, count):
    • ret = list(permutations(plenty, count))
    • return ret
    • def sequence_permutation(t, n):
    • return list(permutations(t, n))

Hello Brainf**k with "default arguments"

The last two BF programs I published would simply print a weirdly formatted string if the input is empty (or not provided), like so: "Hello "/"Hello !". Obviously, that isn't desirable behavior so I refactored my program to print "Hello World!" in case of empty input.

Code
Diff
  • ++++++++++[>+++++++>++++++++++>+++++++++++>+++<<<<-]>++.>+.>--..+++.>++.>->,[.<[+]>,]<[[+]++++++++++[>+++++++++>+++++++++++>++++++++++<<<-]>---.>+.+++.------.>.<<<]<+.
    • ++++++++++[>+++++++>++++++++++>+++++++++++>+++<<<<-]>++.>+.>--..+++.>++.>,[.,]<+.
    • +++++++++++[>+++++++>++++++++++>+++++++++++>+++<<<<-]>++.>+.>--..+++.>++.>->,[.<[+]>,]<[[+]++++++++++[>+++++++++>+++++++++++>++++++++++<<<-]>---.>+.+++.------.>.<<<]<+.