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.
#include <array> template <std::size_t L> long add_arr(std::array<int, L> arr) { long result = 0; for (int i : arr) result += i; return result; } template long add_arr(std::array<int, 9> arr);
- #include <array>
- template <std::size_t L>
- long
add_arr(const unsigned long len, const int arr[len])- add_arr(std::array<int, L> arr)
- {
- long result = 0;
for(unsigned long i = 0;i < len;result += arr[i++]);- for (int i : arr) result += i;
- return result;
}- }
- template long add_arr(std::array<int, 9> arr);
#include <array> #include <criterion/criterion.h> template <std::size_t L> long add_arr(std::array<int, L> arr); Test(add_arr, all) { std::array<int, 9> arr = {1, 2, 3, 4, 5, 6, 7, 8, 9}; cr_assert_eq(add_arr<9>(arr), 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9); std::array<int, 9> arr2 = {1, -2, 3, 4, 5, 6, 7, 8, 9}; cr_assert_eq(add_arr<9>(arr2), 1 + (-2) + 3 + 4 + 5 + 6 + 7 + 8 + 9); }
#include<criterion/criterion.h>- #include <array>
- #include <criterion/criterion.h>
long add_arr(const unsigned long len, const int[len]);- template <std::size_t L>
- long add_arr(std::array<int, L> arr);
Test (add_arr, all) {int arr[] = {1,2,3,4,5,6,7,8,9};cr_assert_eq(add_arr(9, arr), 1+2+3+4+5+6+7+8+9);int arr2[] = {1,-2,3,4,5,6,7,8,9};cr_assert_eq(add_arr(9, arr2), 1+(-2)+3+4+5+6+7+8+9);- Test(add_arr, all)
- {
- std::array<int, 9> arr = {1, 2, 3, 4, 5, 6, 7, 8, 9};
- cr_assert_eq(add_arr<9>(arr), 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9);
- std::array<int, 9> arr2 = {1, -2, 3, 4, 5, 6, 7, 8, 9};
- cr_assert_eq(add_arr<9>(arr2), 1 + (-2) + 3 + 4 + 5 + 6 + 7 + 8 + 9);
- }
no math except subtraction :)
from sys import getsizeof as size def odd_even(n): def odd(): nonlocal n while n>1: n-=2 odd() return size(n)==24
import random- from sys import getsizeof as size
- def odd_even(n):
hashmap = {1: 'True',2: 'False'}maphash = {'True': 1,'False': 0}ebb = random.randint(1000000000000, 9999999999999)flow = random.randint(1000000000000, 9999999999999)power_ball = ebb * flowwhile True:if power_ball == 1:breakfor i in range(power_ball):while power_ball:if ebb >= True and flow <= False:return hashmap.get(2)else:def beta(x):if ebb == pow(flow, 2) and ebb == 1:return hashmap.get(1)else:return (((x * 3) + 6) // 3) - xdef gamma(y):if ebb == flow and flow < pow(ebb, flow):return hashmap.get(1)elif flow == ebb and beta(flow) > ebb:return hashmap.get(2)else:return ((y * 2 + 6) // 2) - ydef yin(x):for i in range(power_ball):if yang(ebb) > gamma(flow):return hashmap.get(2)elif beta(flow) == yang(gamma(flow)):return hashmap.get(1)else:while True:if x <= 1:breakelif x % beta(flow) == yang(ebb) - 1:x //= sum([1, True])elif beta(flow) == beta(ebb) + 1:return hashmap.get(1)elif ord('c') + ord('o') + ord('d') + ord('e') == beta(gamma(flow)):return hashmap.get(2)else:x *= gamma(ebb + flow)x += yang(flow)return xdef yang(x):omega = 777while omega:if gamma(ebb) + gamma(flow) == beta(ebb + flow):return hashmap.get(2)else:while True:if x <= gamma(ebb) - beta(flow):breakelif x % 0o144 - 0x62 == 1:x *= gamma(flow)x += Trueelse:x //= gamma(ebb) - 1omega -= 1return xpower_ball -= 1tik = yin(ebb) + ntok = yang(flow) - nif n % (tik + tok) == (gamma(flow) - beta(ebb)) - 1:return maphash[hashmap.get(1)]else:return maphash[hashmap.get(2)]- def odd():
- nonlocal n
- while n>1:
- n-=2
- odd()
- return size(n)==24
more test cases
added logs
__uint128_t solution(char* str1, char* str2) { __uint128_t result = 0; for (unsigned long i = 0; i < 7; ++i) { result += (((__uint128_t) str1[i]) << (8*(i + 0))) + (((__uint128_t) str2[i]) << (8*(i + 8))); } return result; }
- __uint128_t solution(char* str1, char* str2) {
- __uint128_t result = 0;
- for (unsigned long i = 0; i < 7; ++i) {
- result +=
(((__uint128_t) str1[i]) << (8*i)) +- (((__uint128_t) str1[i]) << (8*(i + 0))) +
- (((__uint128_t) str2[i]) << (8*(i + 8)));
- }
- return result;
- }
#include <stdio.h> #include <string.h> #include <criterion/criterion.h> __uint128_t solution(char* str1, char* str2); #define test_case(name,str1,str2)\ Test(solution, name) {\ __uint128_t name##_r = solution(str1,str2);\ cr_assert_eq(strcmp(((char*) &name##_r)+0,str1),0);\ cr_assert_eq(strcmp(((char*) &name##_r)+8,str2),0);\ printf("solution(\"" str1 "\", \"" str2 "\"); -> {\"%s\\0\", \"%s\\0\"}\n", ((char*) &name##_r)+0, ((char*) &name##_r)+8);\ } test_case(amogus , "amogus ", "so sus!"); test_case(hello , "Hello, ", "World!" ); test_case(ok_guys, "ok " , "guys" );
- #include <stdio.h>
- #include <string.h>
- #include <criterion/criterion.h>
- __uint128_t solution(char* str1, char* str2);
Test(solution, hello_world) {__uint128_t hello_r = solution("hello, ","world!\n");cr_assert_eq(strcmp(((char*) &hello_r)+0,"hello, "),0);cr_assert_eq(strcmp(((char*) &hello_r)+8,"world!\n"),0);printf("%s", ((char*) &hello_r)+0);printf("%s", ((char*) &hello_r)+8);}- #define test_case(name,str1,str2)\
- Test(solution, name) {\
- __uint128_t name##_r = solution(str1,str2);\
- cr_assert_eq(strcmp(((char*) &name##_r)+0,str1),0);\
- cr_assert_eq(strcmp(((char*) &name##_r)+8,str2),0);\
- printf("solution(\"" str1 "\", \"" str2 "\"); -> {\"%s\\0\", \"%s\\0\"}\n", ((char*) &name##_r)+0, ((char*) &name##_r)+8);\
- }
- test_case(amogus , "amogus ", "so sus!");
- test_case(hello , "Hello, ", "World!" );
- test_case(ok_guys, "ok " , "guys" );
A while loop does all the work of iterating every digit in n; first it asks if the digit on the right is 3, and if it is it stops looping. If it is not, and n is still greater than 0, it divides n by 10. If we hit 0 for n we have iterated the entire number, and the loop stops now if it didn't already. This means we just have to check if n is greater than 0 - if it is we stopped early because we found a 3.
using System; public class Kumite { public static bool IsThree(int n) { while(n%10!=3&&n>0)n/=10; return n>0; } }
- using System;
- public class Kumite {
public static bool IsThree(int number) {var digitToSearch = 3;var amountOfDigits = (int)Math.Log10(number);for (int i = 0; i <= amountOfDigits; i++){var divisor = (int)Math.Pow(10, i);var truncate = number / divisor;var digit = truncate % 10;if (digit == digitToSearch){return true;}}return false;- public static bool IsThree(int n) {
- while(n%10!=3&&n>0)n/=10;
- return n>0;
- }
- }
noooooooo pyramids again
def return_hundred(): l = ['a', False, 'капибара', 1000-7 , "eygwqfgeqwte7", True, 100, 100.000000000000000001, "100", 10 ** 10, "xyz"] for i in l: if i == 100: return i break;
- def return_hundred():
def ten():def one():one=lambda a,b,c: 1return one("bad","coding","practice")ten=sum(one() for _ in range(10))return tenreturn ten()*ten()- l = ['a', False, 'капибара', 1000-7 , "eygwqfgeqwte7", True, 100, 100.000000000000000001, "100", 10 ** 10, "xyz"]
- for i in l:
- if i == 100:
- return i
- break;
test.assert_equals(return_hundred(), 100) test.assert_equals(return_hundred(), int('100')) test.assert_equals(return_hundred(), 100 * 0 + 100) #I HATE PYRAMIDS #I HATE PYRAMIDS #I HATE PYRAMIDS #I HATE PYRAMIDS #I HATE PYRAMIDS #I HATE PYRAMIDS #BUT I LIKE SMALL PYRAMIDS #КАПИБАРА ТОП
- test.assert_equals(return_hundred(), 100)
test.assert_equals(return_hundred(), 100 * 1)test.assert_equals(return_hundred(), 50 * 2)test.assert_equals(return_hundred(), 25 * 4)test.assert_equals(return_hundred(), 12.5 * 8)test.assert_equals(return_hundred(), 6.25 * 16)test.assert_equals(return_hundred(), 3.125 * 32)test.assert_equals(return_hundred(), 1.5625 * 64)test.assert_equals(return_hundred(), 0.78125 * 128)test.assert_equals(return_hundred(), 0.390625 * 256)test.assert_equals(return_hundred(), 0.1953125 * 512)test.assert_equals(return_hundred(), 0.09765625 * 1024)test.assert_equals(return_hundred(), 0.048828125 * 2048)test.assert_equals(return_hundred(), 0.0244140625 * 4096)test.assert_equals(return_hundred(), 0.01220703125 * 8192)test.assert_equals(return_hundred(), 0.006103515625 * 16384)test.assert_equals(return_hundred(), 0.0030517578125 * 32768)test.assert_equals(return_hundred(), 0.00152587890625 * 65536)test.assert_equals(return_hundred(), 0.000762939453125 * 131072)test.assert_equals(return_hundred(), 100 / 1)test.assert_equals(return_hundred(), 50 / 0.5)test.assert_equals(return_hundred(), 25 / 0.25)test.assert_equals(return_hundred(), 12.5 / 0.125)test.assert_equals(return_hundred(), 6.25 / 0.0625)test.assert_equals(return_hundred(), 3.125 / 0.03125)test.assert_equals(return_hundred(), 1.5625 / 0.015625)test.assert_equals(return_hundred(), 0.78125 / 0.0078125)test.assert_equals(return_hundred(), 0.390625 / 0.00390625)test.assert_equals(return_hundred(), 0.1953125 / 0.001953125)test.assert_equals(return_hundred(), 0.09765625 / 0.0009765625)test.assert_equals(return_hundred(), 0.048828125 / 0.00048828125)test.assert_equals(return_hundred(), 0.0244140625 / 0.000244140625)test.assert_equals(return_hundred(), 0.01220703125 / 0.0001220703125)test.assert_equals(return_hundred(), 0.006103515625 / 0.00006103515625)test.assert_equals(return_hundred(), 0.0030517578125 / 0.000030517578125)test.assert_equals(return_hundred(), 0.00152587890625 / 0.0000152587890625)test.assert_equals(return_hundred(), 0.000762939453125 / 0.00000762939453125)- test.assert_equals(return_hundred(), int('100'))
- test.assert_equals(return_hundred(), 100 * 0 + 100)
- #I HATE PYRAMIDS
- #I HATE PYRAMIDS
- #I HATE PYRAMIDS
- #I HATE PYRAMIDS
- #I HATE PYRAMIDS
- #I HATE PYRAMIDS
- #BUT I LIKE SMALL PYRAMIDS
- #КАПИБАРА ТОП
use std::io::{Write, Cursor}; fn digits(n: u64) -> usize { n.to_string().len() }
- use std::io::{Write, Cursor};
fn digits(mut n: u64) -> usize {let mut b = [0u8; 20];let mut c = Cursor::new(&mut b[..]);write!(c, "{}", n).unwrap();c.position() as usize- fn digits(n: u64) -> usize {
- n.to_string().len()
- }