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

made it fit on one line :)

Code
Diff
  • max_sequence = lambda arr :max([sum(arr)] + [sum(arr[j:j+i]) for i in range(len(arr)) for j in range(len(arr) - i + 1)])
    • def max_sequence(arr):
    • # Code to find maximum sum of subarray
    • return max(
    • [sum(arr)] +
    • [sum(arr[j:j+i]) for i in range(len(arr)) for j in range(len(arr) - i + 1)]
    • )
    • max_sequence = lambda arr :max([sum(arr)] + [sum(arr[j:j+i]) for i in range(len(arr)) for j in range(len(arr) - i + 1)])
Code
Diff
  • const nums = ['zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine']
    function digitToText(digit) {
      return nums[digit]
    }
    • const nums = ['zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine']
    • function digitToText(digit) {
    • if (digit == 1) {
    • return 'one'
    • }
    • if (digit == 2) {
    • return 'two'
    • }
    • if (digit == 3) {
    • return 'three'
    • }
    • if (digit == 4) {
    • return 'four'
    • }
    • if (digit == 5) {
    • return 'five'
    • }
    • if (digit == 6) {
    • return 'six'
    • }
    • if (digit == 7) {
    • return 'seven'
    • }
    • if (digit == 8) {
    • return 'eight'
    • }
    • if (digit == 9) {
    • return 'nine'
    • }
    • if (digit == 0) {
    • return 'zero'
    • }
    • return nums[digit]
    • }
Code
Diff
  • class Triangle:
    
        @staticmethod
        def other_angle(a, b): 
            return 180 - (a + b)
        
    
        @staticmethod
        def triangle_type_angle(a, b, c):
            if all( angle < 90 for angle in (a, b ,c)):
                return "Acute Triangle"
            if any(angle == 90 for angle in (a, b, c)):
                return "Right Triangle"
            return "Obtuse Triangle"
        
        @staticmethod
        def triangle_type_sides(s1, s2, s3):
            if s1 == s2 == s3:
                return "Equilateral Triangle"
            elif s1 == s2 or s2 == s3 or s1 == s3:
                return "Isoceles Triangle"
            return "Scalene Triangle"
            
    
    • class Triangle:
    • @staticmethod
    • def other_angle(a, b):
    • return 180 - (a + b)
    • @staticmethod
    • def triangle_type_angle(a, b, c):
    • if all( angle < 90 for angle in (a, b ,c)):
    • return "Acute Triangle"
    • if any(angle == 90 for angle in (a, b, c)):
    • return "Right Triangle"
    • return "Obtuse Triangle"
    • @staticmethod
    • def triangle_type_sides(s1, s2, s3):
    • if s1 == s2 == s3:
    • return "Equilateral Triangle"
    • elif s1 == s2 or s2 == s3 or s1 == s3:
    • return "Isoceles Triangle"
    • return "Scalene Triangle"
Code
Diff
  • function sum(a,b) {
      return a+b; // wrong returning
    }
    • function sum(a,b) {
    • return 1; // wrong returning
    • return a+b; // wrong returning
    • }
Fundamentals
Algorithms
Code
Diff
  • const BLOCK_WIDTH: i32 = 274;
    const BLOCK_HEIGHT: i32 = 80;
    const PROBATION_LIMIT: i32 = 2000;
    
    fn goes_to_jail(directions: &[[i32;4]]) -> bool {
        let (mut x, mut y) = (0, 0);
        directions.iter().any(|[north, east, south, west]| {
            x += (east - west) * BLOCK_WIDTH;
            y += (north - south) * BLOCK_HEIGHT;
            x.pow(2) + y.pow(2) > PROBATION_LIMIT.pow(2)      
        })
    }
    • const BLOCK_WIDTH: i32 = 274;
    • const BLOCK_HEIGHT: i32 = 80;
    • const PROBATION_LIMIT: i32 = 2000;
    • fn goes_to_jail(directions: &[[i32;4]]) -> bool {
    • let mut x = 0;
    • let mut y = 0;
    • for [north, east, south, west] in directions {
    • let (mut x, mut y) = (0, 0);
    • directions.iter().any(|[north, east, south, west]| {
    • x += (east - west) * BLOCK_WIDTH;
    • y += (north - south) * BLOCK_HEIGHT;
    • if x.pow(2) + y.pow(2) > PROBATION_LIMIT.pow(2) {
    • return true
    • }
    • }
    • false
    • x.pow(2) + y.pow(2) > PROBATION_LIMIT.pow(2)
    • })
    • }

Added tests for negative integers, modified solution so it doesn't rely on Show instance of Int.

Code
Diff
  • module AreThereThree where
    
    solution :: Int -> Bool
    solution = go . abs
      where
        go 0 = False
        go x = let (x', y) = x `divMod` 10 in y == 3 || go x'
    
    • module AreThereThree where
    • solution :: Int -> Bool
    • solution = elem '3' . show
    • solution = go . abs
    • where
    • go 0 = False
    • go x = let (x', y) = x `divMod` 10 in y == 3 || go x'