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.
class Person: def __init__(self,name,iq=1): self.name=name self.iq= 1 if iq == 0 else iq you = Person("you",0) print(1/you.iq) # hahaha un-rekt!
class Person:def __init__(self,name,iq):self.name=nameself.iq=iqyou=Person("you",0)print(1/you.iq)#ahahaha rekt- class Person:
- def __init__(self,name,iq=1):
- self.name=name
- self.iq= 1 if iq == 0 else iq
- you = Person("you",0)
- print(1/you.iq)
- # hahaha un-rekt!
import codewars_test as test from solution import Person @test.describe("Example") def test_group(): @test.it("test case") def test_case(): p = Person('TestData', 0) test.assert_equals(1 / p.iq, 1.0)
- import codewars_test as test
- from solution import Person
- @test.describe("Example")
- def test_group():
- @test.it("test case")
- def test_case():
- p = Person('TestData', 0)
- test.assert_equals(1 / p.iq, 1.0)
Inspired by PyCalc! https://www.codewars.com/kumite/62347c29a786a2004a613da9?sel=62b1afd8ff12495f950a56d8
A interactive terminal program for making your own directory, at a specific path or the current directory the user is in. Feel free to do what you want with the code.
# importing os import os import sys class CreateDirectory: OPTIONS = {1: "Current Path", 2: "Other Path", 3: "Cancel"} def __init__(self, name=None, path_=None): self.name = name self.path_ = path_ # Function for creating new directory. def create_folder(self, folder_name, dirpath): # Resets color print("\033[0m") if dirpath != 0: print("Checking if path exists...", end="\r") if os.path.exists(dirpath): print("\033[32;1mPath found!\033[0m ") path_ = os.path.join(dirpath, folder_name) else: print("\033[31;1mError:\033[0m Invalid path! ") return False else: # creating a variable path to the new folder. path_ = os.path.join(os.getcwd(), folder_name) # check to see if the folder already exists. print("Checking if directory already exists...", end="\r") if not os.path.exists(path_): # if not, make directory print(f"\033[32;1mDirectory created successfully at {path_}\033[0m ") os.mkdir(path_) return True print("\033[31;1mError:\033[0m Directory already exists! ") return False def display_option_menu(menu_options: dict) -> str: # Some code is taken from PyCalc! for k, v in menu_options.items(): print(f'\t({k})-{v.title()}') while True: user_input = input(f'Select option: (1-{len(menu_options)}):\n{chr(129094)} ') # Validate input: If not a digit or in menu option, continue to ask user for input. if not user_input.isdigit() or int(user_input) not in menu_options: print("\033[31;1mError:\033[0m Invalid input!") continue else: # If input is valid; break. break # Returns user's choice. return menu_options.get(int(user_input)) def main(): # Initializaton of directory creator create = CreateDirectory() create_options = create.OPTIONS while True: print("\033[34;4;1m/ / / TELEVISIONIA's Directory Creator / / /\033[0m") userinput = display_option_menu(create_options) match userinput: case "Current Path": create.create_folder(input("New Directory name: \033[35m"), 0) case "Other Path": create.create_folder(input("New Directory name: \033[35m"), input("\033[0mNew Directory path: \033[35m")) case "Cancel": sys.exit() case _: return main() if __name__ == '__main__': main()
- # importing os
- import os
- import sys
- class CreateDirectory:
- OPTIONS = {1: "Current Path",
- 2: "Other Path",
- 3: "Cancel"}
- def __init__(self, name=None, path_=None):
- self.name = name
- self.path_ = path_
- # Function for creating new directory.
- def create_folder(self, folder_name, dirpath):
- # Resets color
- print("\033[0m")
- if dirpath != 0:
- print("Checking if path exists...", end="\r")
- if os.path.exists(dirpath):
- print("\033[32;1mPath found!\033[0m ")
- path_ = os.path.join(dirpath, folder_name)
- else:
- print("\033[31;1mError:\033[0m Invalid path! ")
- return False
- else:
- # creating a variable path to the new folder.
- path_ = os.path.join(os.getcwd(), folder_name)
- # check to see if the folder already exists.
- print("Checking if directory already exists...", end="\r")
- if not os.path.exists(path_):
- # if not, make directory
- print(f"\033[32;1mDirectory created successfully at {path_}\033[0m ")
- os.mkdir(path_)
- return True
- print("\033[31;1mError:\033[0m Directory already exists! ")
- return False
- def display_option_menu(menu_options: dict) -> str:
- # Some code is taken from PyCalc!
- for k, v in menu_options.items():
- print(f'\t({k})-{v.title()}')
def create_folder(folder_name='MyFolder'):# creating a variable path to the new folder.path_ = os.path.join(os.getcwd(), folder_name)# check to see if the folder already exists.if not os.path.exists(folder_name):# if not, make directoryos.mkdir(folder_name)return Truereturn False- while True:
- user_input = input(f'Select option: (1-{len(menu_options)}):\n{chr(129094)} ')
- # Validate input: If not a digit or in menu option, continue to ask user for input.
- if not user_input.isdigit() or int(user_input) not in menu_options:
- print("\033[31;1mError:\033[0m Invalid input!")
- continue
- else:
- # If input is valid; break.
- break
- # Returns user's choice.
- return menu_options.get(int(user_input))
- def main():
- # Initializaton of directory creator
- create = CreateDirectory()
- create_options = create.OPTIONS
- while True:
- print("\033[34;4;1m/ / / TELEVISIONIA's Directory Creator / / /\033[0m")
- userinput = display_option_menu(create_options)
- match userinput:
- case "Current Path":
- create.create_folder(input("New Directory name: \033[35m"), 0)
- case "Other Path":
- create.create_folder(input("New Directory name: \033[35m"), input("\033[0mNew Directory path: \033[35m"))
- case "Cancel":
- sys.exit()
- case _:
- return main()
- if __name__ == '__main__':
- main()
import codewars_test as test from solution import CreateDirectory # test.assert_equals(actual, expected, [optional] message) @test.describe("Example") def test_group(): @test.it("test case") def test_case(): test.assert_equals(CreateDirectory.create_folder(0, "memes", 0), True) test.assert_equals(CreateDirectory.create_folder(0, "programs", "/workspace/default"), True)
- import codewars_test as test
from solution import create_folder- from solution import CreateDirectory
- # test.assert_equals(actual, expected, [optional] message)
- @test.describe("Example")
- def test_group():
- @test.it("test case")
- def test_case():
test.assert_equals(create_folder(), True)- test.assert_equals(CreateDirectory.create_folder(0, "memes", 0), True)
- test.assert_equals(CreateDirectory.create_folder(0, "programs", "/workspace/default"), True)
#include <string.h> std::string digest(std::string param) { std::string result; for (int i = 0; i < param.size() - 1; i++) { result += param[i]; result += ' '; } result += param[param.size() - 1]; return result; } //Please fix!
- #include <string.h>
- std::string digest(std::string param) {
- std::string result;
for (int i = 0; sizeof(param); i++) {- for (int i = 0; i < param.size() - 1; i++) {
- result += param[i];
- result += ' ';
- }
- result += param[param.size() - 1];
- return result;
- } //Please fix!
function howManyTimesBetween(string $sentence): string { if (!preg_match('/^(?<date1>\d{4}-\d{2}-\d{2}) and (?<date2>\d{4}-\d{2}-\d{2})$/', $sentence, $dates)) { return 'Your question is strange'; } $dates = array_map('date_create', $dates); if (!($diff = $dates['date1']->diff($dates['date2']))->days) { return 'Dates are equals'; } $diffStrings = [$diff->format('%y year(s)'), $diff->format('%m month(s)'), $diff->format('%d day(s)')]; $diffStrings = preg_grep('/^0/', $diffStrings, PREG_GREP_INVERT); return 'There are '.implode(', ', $diffStrings)." between $sentence"; }
- function howManyTimesBetween(string $sentence): string
- {
- if (!preg_match('/^(?<date1>\d{4}-\d{2}-\d{2}) and (?<date2>\d{4}-\d{2}-\d{2})$/', $sentence, $dates)) {
- return 'Your question is strange';
- }
- $dates = array_map('date_create', $dates);
if ($dates['date1'] == $dates['date2']) {return 'Dates are equals';- if (!($diff = $dates['date1']->diff($dates['date2']))->days) {
- return 'Dates are equals';
- }
$diff = $dates['date1']->diff($dates['date2']);- $diffStrings = [$diff->format('%y year(s)'), $diff->format('%m month(s)'), $diff->format('%d day(s)')];
- $diffStrings = preg_grep('/^0/', $diffStrings, PREG_GREP_INVERT);
- return 'There are '.implode(', ', $diffStrings)." between $sentence";
- }
import re def increment_string(s): end_nums = re.match(".+?(\d+)$", s) if end_nums: padded_number = '{:0>{}}'.format(int(end_nums[1])+1, len(end_nums[1])) return s[:end_nums.span(1)[0]] + padded_number return s + '1'
- import re
- def increment_string(s):
if s=="": return "1"s = (s, s+"0")[s[-1].isalpha()]s, number = re.compile("(\D+)(\d+)").match(s).groups()return s+'{:0>{}}'.format(int(number)+1, len(number))- end_nums = re.match(".+?(\d+)$", s)
- if end_nums:
- padded_number = '{:0>{}}'.format(int(end_nums[1])+1, len(end_nums[1]))
- return s[:end_nums.span(1)[0]] + padded_number
- return s + '1'
Find the area of a triangle from its width and height.