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.
Using base-10 logarithm
#include <math.h> typedef signed long long i64; int num_of_digits(i64 n){ i64 k = n < 0 ? -n : n; return log10(k) + 1; }
fn digits(mut n: u64) -> usize {let mut l = 1;while n >= 10 {n /= 10;l += 1;}l}- #include <math.h>
- typedef signed long long i64;
- int num_of_digits(i64 n){
- i64 k = n < 0 ? -n : n;
- return log10(k) + 1;
- }
#include <criterion/criterion.h> #include <stdlib.h> int num_of_digits(long long n); #define test(n, exp, name) Test(Basic_test, test##name) {cr_assert_eq(num_of_digits(n), exp);} test(1, 1, _1_one_d) test(10, 2, _2_two_d) test(12345, 5, _3_longer) test(9876543210, 10, _4_even_longer) test(9223372036854775807, 19, _5_the_longest) test(-20, 2, _6_negative) test(-7382956173, 10, _7_big_negative)
#[test]fn pow10() {assert_eq!(digits(0), 1);for i in 0..20 {assert_eq!(digits(POW10[i]), i+1);}assert_eq!(digits(std::u64::MAX), 20);}- #include <criterion/criterion.h>
- #include <stdlib.h>
#[test]fn pow10_minus_1() {for i in 1..20 {assert_eq!(digits(POW10[i] - 1), i);}}- int num_of_digits(long long n);
#[test]fn pow10_half() {for i in 1..20 {assert_eq!(digits(POW10[i] / 2), i);}}- #define test(n, exp, name) Test(Basic_test, test##name) {cr_assert_eq(num_of_digits(n), exp);}
- test(1, 1, _1_one_d)
- test(10, 2, _2_two_d)
- test(12345, 5, _3_longer)
- test(9876543210, 10, _4_even_longer)
- test(9223372036854775807, 19, _5_the_longest)
- test(-20, 2, _6_negative)
- test(-7382956173, 10, _7_big_negative)
My answer suggests that the meaning of life regards spending your life with a loved one.
from statistics import mean LIVES = 1 SPAN = 72 MONTHS = 12 DAYS = 7 COMPANY = 2 #3's a crowd def meaning_of_life_is(ing=range(LIVES,SPAN//MONTHS*DAYS*COMPANY)): return '{}'.format(mean(ing), 'of', 'life')
def meaning_of_life_is():return """go crazy with your imagination and return anything you like.strings, numbers, ... just don't return None.may the most creative answer win"""- from statistics import mean
- LIVES = 1
- SPAN = 72
- MONTHS = 12
- DAYS = 7
- COMPANY = 2 #3's a crowd
- def meaning_of_life_is(ing=range(LIVES,SPAN//MONTHS*DAYS*COMPANY)):
- return '{}'.format(mean(ing), 'of', 'life')
def prime_checker(n): if n in [2, 3, 5]: return True elif n % 2 == 0 or n % 3 == 0 or n % 5 == 0: return False a = int(n ** 0.5 / 30) b = [7, 11, 13, 17, 19, 23, 29, 31] for i in [30 * j for j in range(a + 1)]: if True in [n % (i + q) == 0 for q in b if i + q is not n]: return False return True
"""https://en.wikipedia.org/wiki/Primality_testThis one has lesser tests or usage of % operator.An alternative using primality mod 30 = 2 * 3 * 5 instead of 6 = 2 * 3"""- def prime_checker(n):
- if n in [2, 3, 5]:
- return True
- elif n % 2 == 0 or n % 3 == 0 or n % 5 == 0:
- return False
- a = int(n ** 0.5 / 30)
- b = [7, 11, 13, 17, 19, 23, 29, 31]
- for i in [30 * j for j in range(a + 1)]:
- if True in [n % (i + q) == 0 for q in b if i + q is not n]:
- return False
- return True
async function a() { return 'ok' } async function b() { try{ const resolve = await a(); console.log(resolve); }catch(reject){ console.log(err); } }
function a() {return new Promise(function (resolve, reject) {resolve('ok');});- async function a() {
- return 'ok'
- }
function b() {a().then(function(res) {console.log(res);}).catch(function(err) {- async function b() {
- try{
- const resolve = await a();
- console.log(resolve);
- }catch(reject){
- console.log(err);
})- }
- }
const main = () => { let a = [1, 2, 3]; let b = [4, 5, 6]; let c = [7, 8, 9]; // converter para ES6 var d = [...a, ...b, ...c]; return d.join(','); }
- const main = () => {
- let a = [1, 2, 3];
- let b = [4, 5, 6];
- let c = [7, 8, 9];
- // converter para ES6
var d = a.concat(b).concat(c);- var d = [...a, ...b, ...c];
- return d.join(',');
- }