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
  • #include <string>
    std::string reverse_string(std::string_view word){
      return {word.rbegin(), word.rend()};
    }
    • #include <string>
    • #include <string_view>
    • std::string reverse_string(std::string_view word){
    • return {word.rbegin(), word.rend()};
    • }

no need for constant since it is only used in one method. uses string formatting instead of concat

Code
Diff
  • public class Greet {
        public String greet(String name){
            return String.format("hello my name is %s", name);
        }
    }
    • public class Greet {
    • private String GREET="hello";
    • public String greet(String name){
    • return GREET.concat(" my name is ").concat(name);
    • return String.format("hello my name is %s", name);
    • }
    • }
Code
Diff
  • def multiply_and_add_one(a, b):
        r = a * b
        return r + 1
    
    • def multiply_and_add_one(a, b):
    • r = 0
    • for i in range(b):
    • r += a
    • r = a * b
    • return r + 1
Code
Diff
  • getIDS <- function(string){
      stringr::str_split(string, "", simplify = TRUE) %>% 
        as.numeric() %>% 
        sum()
    }
    • getIDS <- function(string) {
    • sum(as.integer(strsplit(string, "")[[1]]))
    • }
    • getIDS <- function(string){
    • stringr::str_split(string, "", simplify = TRUE) %>%
    • as.numeric() %>%
    • sum()
    • }

try to format the code properly

Code
Diff
  • fun returnNum(n: Int) = n
    
    • fun returnNum(n:Int)=n
    • fun returnNum(n: Int) = n

Correction of the algorithme

Code
Diff
  • import re
    
    def count(text: str) -> int:
        pattern = r"[aeiouyAEIOUY]"
    
         # Find all vowel matches in the string/text
        matches = re.findall(pattern, text)
    
        # Return the number of vowels
        return len(matches)
    • import re
    • def count(text: str) -> int:
    • ctr = 0
    • vowels = ['a', 'e', 'i', 'o', 'u']
    • for letter in text:
    • if letter.lower() in vowels:
    • ctr += 1
    • pattern = r"[aeiouyAEIOUY]"
    • # Find all vowel matches in the string/text
    • matches = re.findall(pattern, text)
    • return ctr
    • # Return the number of vowels
    • return len(matches)