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.
Inlined
Write a function that accepts an integer (n)
and calculates the multiples of 4 or 6 up to n
but not including the input number n
.
Return the sum of those multiples.
For example:
n = 20 ==> 64
n = 35 ==> 198
n = 120 ==> 2340
def find_multiples(n): total = 0 for i in range(0, n, 2): if i % 4 == 0 or i % 6 == 0: total += i return total
- def find_multiples(n):
- total = 0
- for i in range(0, n, 2):
- if i % 4 == 0 or i % 6 == 0:
- total += i
return total- return total
import codewars_test as test import solution # or from solution import example @test.describe("Example") def test_group(): @test.it("test case") def test_case(): test.assert_equals(find_multiples(20), 64) test.assert_equals(find_multiples(35), 198) test.assert_equals(find_multiples(120), 2340) test.assert_equals(find_multiples(999999), 166665833334)
- import codewars_test as test
- import solution # or from solution import example
- @test.describe("Example")
- def test_group():
- @test.it("test case")
- def test_case():
- test.assert_equals(find_multiples(20), 64)
- test.assert_equals(find_multiples(35), 198)
- test.assert_equals(find_multiples(120), 2340)
- test.assert_equals(find_multiples(999999), 166665833334)
Type checking??
extern printf SECTION .text global hello hello: xor rax, rax mov rdi, msg mov rsi, nasm call printf mov rax, 1 ret SECTION .data msg: db "Hello %s", 10, 0 nasm: db "NASM", 0
#include <iostream>#include <string>- extern printf
int helloCplusplus(){std::string str = "Hello, C++!";std::cout << str << '\n';return 0;}- SECTION .text
- global hello
- hello:
- xor rax, rax
- mov rdi, msg
- mov rsi, nasm
- call printf
- mov rax, 1
- ret
- SECTION .data
- msg: db "Hello %s", 10, 0
- nasm: db "NASM", 0
#include <criterion/criterion.h> int hello(); Test(test, test1){ cr_assert(hello() == 1); }
// TODO: TDD development by writing your own tests as you solve the kata- #include <criterion/criterion.h>
- int hello();
Describe(Group_C_plus_plus){It(test_proper_exit){Assert::That(helloCplusplus(), Equals(0));}};- Test(test, test1){
- cr_assert(hello() == 1);
- }
def converter(number): numbers = ["zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"] if 0 <= number and number <= 9: return numbers[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- numbers = ["zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"]
- if 0 <= number and number <= 9:
- return numbers[number]
- else:
- return number
from re import findall as fa # This can all be done on one line. I expanded it to be easier to read. def to_camel_case(text:str, fw=False) -> str: out = '' for w in fa(r'([a-zA-Z0-9]*)', text): out = f'{out}{(w, w.capitalize())[fw]}' fw = True return out
def to_camel_case(text: str):split_chars = "-_"# loop over each character abovefor split_char in split_chars:split_parts = text.split(split_char)# skip if there was nothing to split onif len(split_parts) == 1:continueparts = []# break up the string in to it's partsfor i, item in enumerate(split_parts):# save the first part but don't change the case of the first letterif i == 0:parts.append(item)continueparts.append(f"{item[0].upper()}{item[1:]}")# join the parts and overwrite the text variable for the next looptext = "".join(parts)return text- from re import findall as fa
- # This can all be done on one line. I expanded it to be easier to read.
- def to_camel_case(text:str, fw=False) -> str:
- out = ''
- for w in fa(r'([a-zA-Z0-9]*)', text):
- out = f'{out}{(w, w.capitalize())[fw]}'
- fw = True
- return out
Write a method that returns the largest integer in the list.
You can assume that the list has at least one element.
.... sorting the array introduced unnecessary time complexity.
import java.util.Arrays; public class Kata { public static int findMax(int[] intArray) { return Arrays.stream(intArray).reduce(Math::max).orElseThrow(); } }
import java.util.*;- import java.util.Arrays;
- 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]);}}- public static int findMax(int[] intArray) {
- return Arrays.stream(intArray).reduce(Math::max).orElseThrow();
- }
- }