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
  • def FindOnly(values):
        for value in set(values):
            if 1 == values.count(value): # check value is unique
                return value
    • def FindOnly(list):
    • comparable_list = [(str(x), i) for i, x in enumerate(list)]
    • comparable_list.sort()
    • for i in range(-1, len(list)-1):
    • if comparable_list[i][0] != comparable_list[i-1][0] and comparable_list[i][0] != comparable_list[i+1][0]:
    • return list[comparable_list[i][1]]
    • def FindOnly(values):
    • for value in set(values):
    • if 1 == values.count(value): # check value is unique
    • return value

Trimmed the lambda

Code
Diff
  • function getGemsOfColor(color, gems) {
      return gems.filter(gem => gem.colors.includes(color)).map(it => it.name).sort();
    }
    • function getGemsOfColor(color, gems) {
    • return gems.filter(gem => gem.colors.includes(color)).map(it => {return it.name}).sort();
    • return gems.filter(gem => gem.colors.includes(color)).map(it => it.name).sort();
    • }
Code
Diff
  • fn foo() -> i32 {
        2
    }
    • fn foo() -> i32 {
    • 0
    • 2
    • }

I suggest first converting the string to lower case so you don't need to add the conditional for checking for the uppercase 'A'.

Code
Diff
  • count=str=>str.toLowerCase().split("").filter(x=>x=="a").length;
    • count=str=>str.split("").filter(x=>x=="a"||x=="A").length;
    • count=str=>str.toLowerCase().split("").filter(x=>x=="a").length;
Code
Diff
  • function returnhundred(n = 0) {
      if (n % 5 - 4 || n % 11) return returnhundred(n + 3);
      return n + 1;
    }
    • function returnhundred() {
    • return 10 ** 2;
    • function returnhundred(n = 0) {
    • if (n % 5 - 4 || n % 11) return returnhundred(n + 3);
    • return n + 1;
    • }
Code
Diff
  • def primemaker(x):
      primes = []
      if x < 2 : return []
      else:  
        primes.append(2)
        for possibleprimes in range(3,(x+1), 2): # only odd numbers 
            isprime = True
            for n in range(2,possibleprimes//2+1):
                if possibleprimes % n == 0:
                    isprime = False
                    break # stop after first non prime number found
            if isprime:
                primes.append(possibleprimes)
        return primes
    
    
    • def primemaker(x):
    • primes = []
    • if x < 2 : return []
    • else:
    • for possibleprimes in range(2,(x+1)):
    • primes.append(2)
    • for possibleprimes in range(3,(x+1), 2): # only odd numbers
    • isprime = True
    • for n in range(2,possibleprimes//2+1):
    • if possibleprimes % n == 0:
    • isprime = False
    • break # stop after first non prime number found
    • if isprime:
    • primes.append(possibleprimes)
    • return primes
Code
Diff
  • export function reverseInt(n: number) {
      return +String(n).split('').reverse().join('')
    }
    • export function reverseInt(n: number) {
    • return parseInt(new String(n).split('').reverse().join(''))
    • return +String(n).split('').reverse().join('')
    • }