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
Code
Diff
  • class Student:
        def __init__(self, first_name, last_name, grades=[]):
            self.first_name = first_name
            self.last_name = last_name
            self.grades = grades
    
        @property
        def full_name(self):
            return f'{self.first_name} {self.last_name}'
    
        @property
        def email(self):
            return f'{self.first_name}{self.last_name[0]}@codewars.com'
    
        @property
        def grade_average(self):
            return sum(self.grades) / len(self.grades)
    
        def assess(self):
            grades = [('A', 90), ('B', 80), ('C', 70), ('D', 65)]
            avg = self.grade_average
            for grade in grades:
                if avg >= grade[1]:
                    return grade[0]
            return 'F'
                
    • class Student:
    • def __init__(self, first_name, last_name, grades=None):
    • def __init__(self, first_name, last_name, grades=[]):
    • self.first_name = first_name
    • self.last_name = last_name
    • self.grades = [] if grades is None else grades
    • self.grades = grades
    • @property
    • def full_name(self):
    • return f'{self.first_name} {self.last_name}'
    • @property
    • def email(self):
    • return f'{self.first_name}{self.last_name[0]}@codewars.com'
    • @property
    • def grade_average(self):
    • return sum(self.grades) / len(self.grades)
    • def assess(self):
    • if self.grade_average >= 90:
    • return "A"
    • if self.grade_average >= 80:
    • return "B"
    • if self.grade_average >= 70:
    • return "C"
    • if self.grade_average >= 65:
    • return "D"
    • return "F"
    • grades = [('A', 90), ('B', 80), ('C', 70), ('D', 65)]
    • avg = self.grade_average
    • for grade in grades:
    • if avg >= grade[1]:
    • return grade[0]
    • return 'F'

Make it a real amogus

Code
Diff
  • // sus amogus
    int foo() { return 0; }
    int fоo() { return 0; }
    int foо() { return 0; }
    • // Among us
    • // sus amogus
    • int foo() { return 0; }
    • int bar() { return 0; }
    • int baz() { return 0; }
    • int fоo() { return 0; }
    • int foо() { return 0; }
Code
Diff
  • int doubleValue(int x) {
        return x * 2;
    }
    
    • #include<iostream>
    • int doubleValue(int x) {
    • return x * 2;
    • }
Code
Diff
  • const sayHelloWorld = (name) => `Hello World ${name}`
    • function sayHelloWorld(name){
    • }
    • const sayHelloWorld = (name) => `Hello World ${name}`

Shorter but not necessary as readable. I chose to break the line at what i would consider each thought. Like an "if, else"
"If #calculations# is true? Do this. Otherwise keep going"
"If #calculations# is true? Do this. Otherwise keep going"
"If #calculations# is true? Do this. Otherwise keep going"
Chould definitely be a oneliner, but in my opinion oneLiners makes it less readable which will make it harder for the next programmer to understand.

Code
Diff
  • // Fizz buzz is a popular computer science interview question.  
    // The function above is given a number - if the number is
    // divisible by 3, return "fizz", if it's divisible by 5, 
    // return "buzz", if not divisble by 3 or 5 - return the
    // number itself.
    public class FizzBuzz
    {
        public string GetOutput(int number) {
          return (number % 15 == 0) ? "FizzBuzz":
            (number % 3 == 0) ? "Fizz":
            (number % 5 == 0) ? "Buzz":
            number.ToString();      
        }
    }
    • // Fizz buzz is a popular computer science interview question.
    • // The function above is given a number - if the number is
    • // divisible by 3, return "fizz", if it's divisible by 5,
    • // return "buzz", if not divisble by 3 or 5 - return the
    • // number itself.
    • public class FizzBuzz
    • {
    • public string GetOutput(int number) {
    • if (number % 15 == 0) {
    • return "FizzBuzz";
    • }
    • else if (number % 3 == 0) {
    • return "Fizz";
    • }
    • else if (number % 5 == 0) {
    • return "Buzz";
    • }
    • else {
    • return number.ToString();
    • }
    • // Fizz buzz is a popular computer science interview question.
    • // The function above is given a number - if the number is
    • // divisible by 3, return "fizz", if it's divisible by 5,
    • // return "buzz", if not divisble by 3 or 5 - return the
    • // number itself.
    • return (number % 15 == 0) ? "FizzBuzz":
    • (number % 3 == 0) ? "Fizz":
    • (number % 5 == 0) ? "Buzz":
    • number.ToString();
    • }
    • }
Code
Diff
  • module Kata where
    
    add_ :: Int -> Int -> Int
    add_ a b = b + a
    • module Kata where
    • add_ :: Int -> Int -> Int
    • add_ a b = a + b
    • add_ a b = b + a
Code
Diff
  • even_or_odd = lambda x: "Even" if x%2==0 else "Odd"
    • even_or_odd = lambda x: "Even" if x&1==0 else "Odd"
    • even_or_odd = lambda x: "Even" if x%2==0 else "Odd"

You are given an array with N numbers. N - 1 numbers are the same. You must find the unique number.

  • The input array will always have at least 3 numbers.
  • The input array can be very large. Be mindful of performance.

DO NOT USE GOOGLE!!!

DO NOT LOOK AT OTHER SUBMISSIONS!!!

DO NOT EDIT THE TEST CASES!!!

findUniqueNumber([ 1; 1; 1; 2; 1; 1 ]) = 2

findUniqueNumber([ 0; 0; 0.55; 0; 0 ]) = 0.55

Code
Diff
  • module ExampleSolution
    
      let findUniqueNumber array =
        () // your code goes here
    • module ExampleSolution
    • let findUniqueNumber array =
    • ()
    • () // your code goes here
Code
Diff
  • function caps(string $c): string {
        return ucwords($c);
    }
    • function caps($c) {
    • return ucwords($c);
    • function caps(string $c): string {
    • return ucwords($c);
    • }