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
  • fn solution(x: i32) -> bool {
        x.to_string().chars().any(|s| s == '3')
    }
    • fn solution(mut x: i32) -> bool {
    • match x.to_string().chars().into_iter().position(|s| s == '3') {
    • Some(_t) => true,
    • _e => false,
    • }
    • fn solution(x: i32) -> bool {
    • x.to_string().chars().any(|s| s == '3')
    • }

Shorter number converter, Using a if instead of a switch.

Code
Diff
  • def converter(number):
        nums = ['zero', 'one','two','three','four','five','six','seven','eight','nine']
        if number < len(nums):
            return nums[int(number)]
        else:
            return number
    
    • def converter(number):
    • match number:
    • case 0:
    • return 'zero'
    • case 1:
    • return 'one'
    • case 2:
    • return 'two'
    • case 3:
    • return 'three'
    • case 4:
    • return 'four'
    • case 5:
    • return 'five'
    • case 6:
    • return 'six'
    • case 7:
    • return 'seven'
    • case 8:
    • return 'eight'
    • case 9:
    • return 'nine'
    • case _:
    • return number
    • nums = ['zero', 'one','two','three','four','five','six','seven','eight','nine']
    • if number < len(nums):
    • return nums[int(number)]
    • else:
    • return number

Create a function that checks if a number n is divisible by two numbers x AND y. All inputs are positive, non-zero digits.

Examples:

  1. n = 3, x = 1, y = 3 => true because 3 is divisible by 1 and 3
  2. n = 12, x = 2, y = 6 => true because 12 is divisible by 2 and 6
  3. n = 100, x = 5, y = 3 => false because 100 is not divisible by 3
  4. n = 12, x = 7, y = 5 => false because 12 is neither divisible by 7 nor 5

GitHub

Jeddi's Profile Views

Code
Diff
  • pub fn is_divisible(n: i32, x: i32, y:i32) -> bool {
        match (n % x == 0, n % y == 0) {
            (true, true) => true,
                       _ => false
        }
    }
    • function isDivisible(n, x, y) {
    • if (n % x === 0 && n % y === 0) {
    • return true
    • } else {
    • return false
    • }
    • pub fn is_divisible(n: i32, x: i32, y:i32) -> bool {
    • match (n % x == 0, n % y == 0) {
    • (true, true) => true,
    • _ => false
    • }
    • }
Arrays
Fundamentals

In this Kata your job is to find the biggest Integer in an Array and return it as such.

'1,2,3,4' -> '4'

The Integers passed can be non-negativ but will always be valid numbers.

Code
Diff
  • import java.util.*;
    
    public class Kata {
        public static int findMax(int[] my_array) {
          
          int max = my_array[0];
          
          for(int i : my_array) {
            if(i > max) max = i;
          }
          
          return max;
        }
    }
    • import java.util.*;
    • public class Kata {
    • public static int findMax(int[] my_array) {
    • // Write a method that returns the largest integer in the list.
    • // You can assume that the list has at least one element.
    • Arrays.sort(my_array);
    • return (my_array[my_array.length-1]);
    • int max = my_array[0];
    • for(int i : my_array) {
    • if(i > max) max = i;
    • }
    • return max;
    • }
    • }
Code
Diff
  • import re
    
    def to_camel_case(s: str):
        return '' if s == '' else ''.join([el.capitalize() if i == 0  and not ''.join(s)[0].islower() else el.lower() if i == 0 and ''.join(s)[0].islower() else el.capitalize() for (i, el) in enumerate(re.split(re.compile(r'[-_ ]') , s))])
        
    • def to_camel_case(text: str):
    • split_chars = "-_"
    • # loop over each character above
    • for split_char in split_chars:
    • split_parts = text.split(split_char)
    • # skip if there was nothing to split on
    • if len(split_parts) == 1:
    • continue
    • parts = []
    • # break up the string in to it's parts
    • for i, item in enumerate(split_parts):
    • # save the first part but don't change the case of the first letter
    • if i == 0:
    • parts.append(item)
    • continue
    • parts.append(f"{item[0].upper()}{item[1:]}")
    • # join the parts and overwrite the text variable for the next loop
    • text = "".join(parts)
    • return text
    • import re
    • def to_camel_case(s: str):
    • return '' if s == '' else ''.join([el.capitalize() if i == 0 and not ''.join(s)[0].islower() else el.lower() if i == 0 and ''.join(s)[0].islower() else el.capitalize() for (i, el) in enumerate(re.split(re.compile(r'[-_ ]') , s))])
Code
Diff
  • def meaning_of_life_is(*args): return 6*7
    • def meaning_of_life_is(*args): return 40 + 2
    • def meaning_of_life_is(*args): return 6*7

added two new functions Nor and Nand

Code
Diff
  • bool Or(bool a, bool b) {
        return a+b;
    }
    bool And(bool a, bool b) {
        return a*b;
    }
    bool Xor(bool a, bool b) {
        return a!=b;
    }
    bool Nor(bool a, bool b) {
        return !(a+b);
    }
    bool Nand(bool a, bool b) {
        return !(a*b);
    }
    • bool Or(bool a, bool b) {
    • return a+b;
    • }
    • bool And(bool a, bool b) {
    • return a*b;
    • }
    • bool Xor(bool a, bool b) {
    • return a!=b;
    • }
    • bool Nor(bool a, bool b) {
    • return !(a+b);
    • }
    • bool Nand(bool a, bool b) {
    • return !(a*b);
    • }
Code
Diff
  • module Knot where
    onesAndZeroes= 1 : 0 : onesAndZeroes
    • module Knot where
    • onesAndZeroes=map(flip mod 2)[1..]
    • onesAndZeroes= 1 : 0 : onesAndZeroes