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
  • package kata
    
    func Multiple3And5(number int) int {
    	sum := 0
    	for i := 3; i < number; i++ {
    		if i%15 == 0 {
    			sum += i
    			continue
    		}
    		if i%3 == 0 {
    			sum += i
    		}
    		if i%5 == 0 {
    			sum += i
    		}
    	}
    	return sum
    }
    • package kata
    • func Multiple3And5(number int) int {
    • sum := 0
    • for i := 3; i < number; i++ {
    • if i%15 == 0 {
    • sum += i
    • continue
    • }
    • if i%3 == 0 {
    • sum += i
    • }
    • if i%5 == 0 {
    • sum += i
    • }
    • }
    • return sum
    • }

No need to "branch to boolean". You can just return the condition.
You can also add " " to the list of characters to remove (which was just punctuation before) instaead of having a separate call to replace.

Code
Diff
  • import string
    
    def is_palindrome(s: str) -> bool:
        forward = s.lower().translate(str.maketrans('', '', string.punctuation + ' '))
        return forward == forward[::-1]
    • import string
    • def is_palindrome(s: str) -> bool:
    • forward = s.lower().replace(" ", "").translate(str.maketrans('', '', string.punctuation))
    • reverse = forward[::-1]
    • if forward == reverse:
    • return True
    • else:
    • return False
    • forward = s.lower().translate(str.maketrans('', '', string.punctuation + ' '))
    • return forward == forward[::-1]
Code
Diff
  • int doubleValue(int x) {
      return x*2;
    }
    • int doubleValue(int x) {
    • return x<<1;
    • }
    • return x*2;
    • }

Uglifyed it to it's limit. But I like it.

Code
Diff
  • pyramid_of_x=lambda n:['\n'.join(['*'*(i+1) for i in range(n)]),'Not enough building blocks!'][n<2]
    • def pyramid_of_x(n):
    • if n < 2:
    • return 'Not enough building blocks!'
    • rows = ['*' * i for i in range(1, n + 1)]
    • return '\n'.join(rows)
    • pyramid_of_x=lambda n:['\n'.join(['*'*(i+1) for i in range(n)]),'Not enough building blocks!'][n<2]

const addArr

Code
Diff
  • const addArr = (arr) => arr.reduce((acc, i) => acc + i, 0) || null
    • const addArr = (arr) => {
    • let sum = 0;
    • for (let i = 0; i < arr.length; i++) {
    • sum += arr[i];
    • }
    • return sum || null;
    • };
    • const addArr = (arr) => arr.reduce((acc, i) => acc + i, 0) || null
Code
Diff
  • select 
      city_name, 
      sum(confirmed_cases) confirmed_cases , 
      sum(recovered_cases) recovered_cases, 
      sum(death_cases) death_cases
    from cases
      join dati
      on dati.code = cases.dati_code
    group by city_name
    order by confirmed_cases desc;
    • -- Code Here
    • select
    • city_name,
    • sum(confirmed_cases) confirmed_cases ,
    • sum(recovered_cases) recovered_cases,
    • sum(death_cases) death_cases
    • from cases
    • join dati
    • on dati.code = cases.dati_code
    • group by city_name
    • order by confirmed_cases desc;
Code
Diff
  • def return_hundred():
        a = 99 + 1
        return a
    
    • def return_hundred():
    • kk = 100
    • return kk * 10000000000000000000000000000000000000000000000 // 10000000000000000000000000000000000000000000000
    • a = 99 + 1
    • return a
Code
Diff
  • -- Buatlah query sql untuk mendapatkan 10 pegawai dengan gaji terbesar.
    select * from employees order by salary desc limit 10;
    • --- Code Here
    • -- Buatlah query sql untuk mendapatkan 10 pegawai dengan gaji terbesar.
    • select * from employees order by salary desc limit 10;
Code
Diff
  • -- Code Here
    
    select * 
    from transactions
    where customer is not null
    order by store, total_price desc
    • --- Code Here
    • -- Code Here
    • select *
    • from transactions
    • where customer is not null
    • order by store, total_price desc
Code
Diff
  • -- Code Here
    SELECT *
    FROM transactions
    ORDER BY total_price DESC;
    • --- Code Here
    • -- Code Here
    • SELECT *
    • FROM transactions
    • ORDER BY total_price DESC;