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.
from functools import reduce prod =lambda n:reduce(lambda x,y:x*y,n if n else[0])
from itertools import productdef prod(n):if not n:return 0n = n[-1]fact = lambda x: x if x <= 2 else x*fact(x-1)return fact(n)- from functools import reduce
- prod =lambda n:reduce(lambda x,y:x*y,n if n else[0])
def get_nth_words(text, n): return '' if n <= 0 else ' '.join([word for word in text.split()][n - 1::n])
- def get_nth_words(text, n):
if n <= 0:return ""words = text.split()nth_words = [word for word in words[n-1 : : n]]return " ".join(nth_words)- return '' if n <= 0 else ' '.join([word for word in text.split()][n - 1::n])
int reverse_int_recc(int num, int rev) { return (num == 0) ? rev : reverse_int_recc(num / 10, rev * 10 + (num % 10)); } int reverse_int(int num) { return reverse_int_recc(num, 0); }
int reverse_int(int num){int rev = 0;num *= 10;while(num /= 10)rev = rev * 10 + num % 10;return rev;}- int reverse_int_recc(int num, int rev) {
- return (num == 0) ? rev : reverse_int_recc(num / 10, rev * 10 + (num % 10));
- }
- int reverse_int(int num) {
- return reverse_int_recc(num, 0);
- }
converter = lambda n: ["zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"][n] if n < 10 else None
def converter(number):try:return ["zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"][number]except IndexError:return None- converter = lambda n: ["zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"][n] if n < 10 else None
Very readable solution (though not tail-recursive).
Could be used as spec for quick check based tests in case a more performant solution is required.
module Platforms where platforms :: [Integer] -> Integer platforms (x:y:xs) = abs (x - y) + platforms (y:xs) platforms _ = 0
- module Platforms where
- platforms :: [Integer] -> Integer
platforms xs = sum $ zipWith energy xs (tail xs)whereenergy x y = abs (x - y)- platforms (x:y:xs) = abs (x - y) + platforms (y:xs)
- platforms _ = 0