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.
:D
from math import sqrt def is_prime(num): for newnum in range(2, int(sqrt(num)) + 1): if num % newnum == 0: return False return False if num == 1 else True def get_primes(num): return [n for n in range(1, num + 1) if is_prime(n)]
- from math import sqrt
- def is_prime(num):
newnum = num - 1while newnum > 1:if num % newnum == 0:return Falsenewnum -= 1if newnum > 1:continuereturn True- for newnum in range(2, int(sqrt(num)) + 1):
- if num % newnum == 0:
- return False
- return False if num == 1 else True
- def get_primes(num):
og, c = num, []while num > 0:if is_prime(num):c.append(num)num -= 1if og > 1:c.append(2)return sorted(c, reverse=False)- return [n for n in range(1, num + 1) if is_prime(n)]
test.assert_equals(get_primes(10), [2, 3, 5, 7]) test.assert_equals(get_primes(50), [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47]) test.assert_equals(get_primes(100), [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]) test.assert_equals(len(get_primes(10000)), 1229) test.assert_equals(len(get_primes(1000000)), 78498)
- test.assert_equals(get_primes(10), [2, 3, 5, 7])
- test.assert_equals(get_primes(50), [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47])
- test.assert_equals(get_primes(100), [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97])
test.assert_equals(len(get_primes(10000)), 1229)- test.assert_equals(len(get_primes(10000)), 1229)
- test.assert_equals(len(get_primes(1000000)), 78498)
FizzBuzz using pattern matching
using System; namespace Solution { class FizzBuzz { public static string Convert(int input) => input switch { {} when input.IsDivisibleBy(3) && input.IsDivisibleBy(5) => "FizzBuzz", {} when input.IsDivisibleBy(3) => "Fizz", {} when input.IsDivisibleBy(5) => "Buzz", _ => input.ToString() }; } static class IntExtensions { public static bool IsDivisibleBy(this int dividend, int divisor) => dividend % divisor == 0; } }
- using System;
- namespace Solution {
- class FizzBuzz {
public static string Convert(int input){var divisableBy3 = input % 3 == 0;var divisableBy5 = input % 5 == 0;return (!divisableBy3 & !divisableBy5) ? input.ToString(): (divisableBy3 ? "Fizz" : string.Empty) + (divisableBy5 ? "Buzz" : string.Empty);}- public static string Convert(int input) => input switch
- {
- {} when input.IsDivisibleBy(3) && input.IsDivisibleBy(5) => "FizzBuzz",
- {} when input.IsDivisibleBy(3) => "Fizz",
- {} when input.IsDivisibleBy(5) => "Buzz",
- _ => input.ToString()
- };
- }
- static class IntExtensions {
- public static bool IsDivisibleBy(this int dividend, int divisor) => dividend % divisor == 0;
- }
- }