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.

Code
Diff
  • module FindMaxNumber where
    
    find_max :: Ord a => [a] -> a
    find_max [] = error "find_max: Empty list"
    find_max (x:xs) = foldr (\ a b -> if a > b then a else b) x xs
    
    • module FindMaxNumber where
    • find_max :: Ord a => [a] -> a
    • find_max = maximum
    • find_max [] = error "find_max: Empty list"
    • find_max (x:xs) = foldr (\ a b -> if a > b then a else b) x xs
rowcasedvs.Whoop!5 years ago

2048

:=

Code
Diff
  • calculate_2048=lambda s:(2**(x:=s*s+1),(2**(x+1))-4)
    • def calculate_2048(size):
    • highest = 2 ** (size**2 + 1)
    • sumtotal = (2 ** (size**2 + 2)) - 4
    • return highest, sumtotal
    • calculate_2048=lambda s:(2**(x:=s*s+1),(2**(x+1))-4)
Code
Diff
  • fn flip_the_number(x: &u64) -> u64 {
        x.to_string().chars().rev().collect::<String>().parse::<u64>().unwrap()
    }
    • def flip_the_number(x):
    • return int(str(x)[::-1])
    • fn flip_the_number(x: &u64) -> u64 {
    • x.to_string().chars().rev().collect::<String>().parse::<u64>().unwrap()
    • }
Guslarzvs.terrierscript5 years agoFailed Tests

Return 100

Code
Diff
  • function returnhundred() 
    {
      return (''+[][0]).charCodeAt(2)
    }
    • function returnhundred() {
    • return (undefined +"")[2].charCodeAt();
    • function returnhundred()
    • {
    • return (''+[][0]).charCodeAt(2)
    • }
Numbers
Data Types
Integers
Algorithms
Logic
Code
Diff
  • fn digits(n: u64) -> usize {
        match n {
            0 => 1,
            _ => (n as f64).log10().floor() as usize + 1
        }
    }
    • fn digits(n: u64, base: u64) -> usize {
    • digits_iter(n, base).count()
    • }
    • fn digits_iter(n: u64, base: u64) -> impl Iterator<Item = u64> {
    • let mut n = Some(n);
    • std::iter::from_fn(move || match n {
    • Some(x) => {
    • let digit = x % base;
    • n = Some(x / base);
    • if let Some(0) = n {
    • n = None;
    • }
    • Some(digit)
    • }
    • _ => None,
    • })
    • }
    • fn digits(n: u64) -> usize {
    • match n {
    • 0 => 1,
    • _ => (n as f64).log10().floor() as usize + 1
    • }
    • }