Begin a new Kumite
Search
About
  • Filter by Language:
  • 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.

Strings
Code
Diff
  • module Format where
    
    import Data.Bits ((.|.))
    import Data.Char (chr)
    
    f :: Integer -> [Char]
    f n = f' [chr $ (.|.) 48 $ fromIntegral $ mod n 10] (div n 10) where
      f' :: [Char] -> Integer -> [Char]
      f' sol 0 = sol
      f' acc n = f'' ((:) (chr $ (.|.) 48 $ fromIntegral $ mod n 10) acc) (div n 10) where
        f'' :: [Char] -> Integer -> [Char]
        f'' sol 0 = sol
        f'' acc n = f''' ((:) (chr $ (.|.) 48 $ fromIntegral $ mod n 10) acc) (div n 10) where
          f''' :: [Char] -> Integer -> [Char]
          f''' sol 0 = sol
          f''' acc n = f' ((:) (chr $ (.|.) 48 $ fromIntegral $ mod n 10) $ (:) ',' acc) (div n 10) 
  • 1
    def f(n):
    
    2
        G = 3
    
    3
        s = str(n)
    
    4
        r = len(s) % G
    
    5
        def make(s):
    
    6
            if r:
    
    7
                yield s[:r]
    
    8
            for i in range(r, len(s), G):
    
    9
                yield s[i:i+G]
    
    10
        return ','.join(make(s))
    
    1+
    module Format where
    
    2+
    3+
    import Data.Bits ((.|.))
    
    4+
    import Data.Char (chr)
    
    5+
    6+
    f :: Integer -> [Char]
    
    7+
    f n = f' [chr $ (.|.) 48 $ fromIntegral $ mod n 10] (div n 10) where
    
    8+
      f' :: [Char] -> Integer -> [Char]
    
    9+
      f' sol 0 = sol
    
    10+
      f' acc n = f'' ((:) (chr $ (.|.) 48 $ fromIntegral $ mod n 10) acc) (div n 10) where
    
    11+
        f'' :: [Char] -> Integer -> [Char]
    
    12+
        f'' sol 0 = sol
    
    13+
        f'' acc n = f''' ((:) (chr $ (.|.) 48 $ fromIntegral $ mod n 10) acc) (div n 10) where
    
    14+
          f''' :: [Char] -> Integer -> [Char]
    
    15+
          f''' sol 0 = sol
    
    16+
          f''' acc n = f' ((:) (chr $ (.|.) 48 $ fromIntegral $ mod n 10) $ (:) ',' acc) (div n 10) 
    

Recent Moves:

Code
Diff
  • revstr=s=>[...s].reverse().join``
  • 1
    function revstr(str) {
    
    2
      return str.split("").reverse().join("")
    
    3
    }
    
    1+
    revstr=s=>[...s].reverse().join``
    

Recent Moves:

Not going to replace the // with a / in this fork.

Code
Diff
  • """
    d=lambda x:d(x//10)+x%10 if x>9 else x
    """
    d=lambda x:(x>9and d(x//10))+x%10
    a=lambda m,s,p:d(m)<d(s)+d(p)
  • 1+
    """
    
    11
    d=lambda x:d(x//10)+x%10 if x>9 else x
    
    3+
    """
    
    4+
    d=lambda x:(x>9and d(x//10))+x%10
    
    22
    a=lambda m,s,p:d(m)<d(s)+d(p)