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.
def letter(str): result = [] words = [x for x in str.lower().strip().split() if x] mx = len(max(words, key=len)) if words else 0 starts = set(x[:i] for x in words for i in range(1, mx+1)) for s in starts: matching = [word for word in words if word.startswith(s)] if len(matching) == len(s): result += matching return sorted(result)
import re- def letter(str):
words = re.sub(r"[^a-z]", " ", str.lower()).split(" ")lst = []l1 = []l2 = []sol = []for x in words:word = ""for y in x:word += ylst.append(word)for x in sorted(set(lst)):for y in words:if y.startswith(x):l1.append(y)l2.append(list(l1))l1.clear()dic = dict(zip(sorted(set(lst)), l2))for k, v in dic.items():if len(k) == len(v):for x in v:sol.append(x)return sorted(sol)- result = []
- words = [x for x in str.lower().strip().split() if x]
- mx = len(max(words, key=len)) if words else 0
- starts = set(x[:i] for x in words for i in range(1, mx+1))
- for s in starts:
- matching = [word for word in words if word.startswith(s)]
- if len(matching) == len(s):
- result += matching
- return sorted(result)
fork dos
class Account { private int balance = 0; public void deposit(int amount) throws IllegalArgumentException { if(amount < 0) { throw new IllegalArgumentException("You cannot deposit negative money!"); } balance += amount; } public void withdraw(int amount) throws IllegalArgumentException { if (amount < 0) { throw new IllegalArgumentException("You cannot withdraw negative money!"); } if(amount > balance) { throw new IllegalArgumentException("You cannot withdraw more than you have!"); } balance -= amount ; } public String getStatement() { return String.valueOf(balance); } }
- class Account {
- private int balance = 0;
void deposit(int amount){- public void deposit(int amount) throws IllegalArgumentException {
- if(amount < 0) {
- throw new IllegalArgumentException("You cannot deposit negative money!");
- }
- balance += amount;
- }
void withdraw(int amount) throws IllegalArgumentException{- public void withdraw(int amount) throws IllegalArgumentException {
- if (amount < 0) {
- throw new IllegalArgumentException("You cannot withdraw negative money!");
- }
- if(amount > balance) {
- throw new IllegalArgumentException("You cannot withdraw more than you have!");
- }
- balance -= amount ;
- }
String getStatement() {- public String getStatement() {
- return String.valueOf(balance);
- }
- }
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.BeforeEach; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertThrows; class AccountTest { private Account account; @BeforeEach public void setUp() { this.account = new Account(); } @Test void deposit_adds_money_to_initial_balance() { account.deposit(100); String statement = account.getStatement(); assertEquals("100", statement); } @Test void deposit_adds_different_amount_of_money_to_initial_balance(){ account.deposit(200); String statement = account.getStatement(); assertEquals("200", statement); } @Test void withdraw_of_zero_balance_remains_same(){ account.withdraw(0); String statement = account.getStatement(); assertEquals("0", statement); } @Test void withdraw_reduces_balance_by_amount_withdrawn(){ account.deposit(500); account.withdraw(100); String statement = account.getStatement(); assertEquals("400", statement); } @Test void cannot_withdraw_more_than_you_have() { account.deposit(100); assertThrows(IllegalArgumentException.class, () -> { account.withdraw(200); }); } @Test void cannot_withdraw_negative_money() { assertThrows(IllegalArgumentException.class, () -> { account.withdraw(-100); }); } @Test void cannot_deposit_negative_money() { assertThrows(IllegalArgumentException.class, () -> { account.deposit(-100); }); } }
- import org.junit.jupiter.api.Test;
- import org.junit.jupiter.api.BeforeEach;
- import static org.junit.jupiter.api.Assertions.assertEquals;
- import static org.junit.jupiter.api.Assertions.assertThrows;
- class AccountTest {
- private Account account;
- @BeforeEach
- public void setUp() {
- this.account = new Account();
- }
- @Test
- void deposit_adds_money_to_initial_balance() {
Account account = new Account();- account.deposit(100);
- String statement = account.getStatement();
- assertEquals("100", statement);
- }
- @Test
- void deposit_adds_different_amount_of_money_to_initial_balance(){
Account account = new Account();- account.deposit(200);
- String statement = account.getStatement();
- assertEquals("200", statement);
- }
- @Test
- void withdraw_of_zero_balance_remains_same(){
Account account = new Account();- account.withdraw(0);
- String statement = account.getStatement();
- assertEquals("0", statement);
- }
- @Test
- void withdraw_reduces_balance_by_amount_withdrawn(){
Account account = new Account();- account.deposit(500);
- account.withdraw(100);
- String statement = account.getStatement();
- assertEquals("400", statement);
- }
- @Test
- void cannot_withdraw_more_than_you_have() {
Account account = new Account();- account.deposit(100);
- assertThrows(IllegalArgumentException.class, () -> { account.withdraw(200); });
- }
- @Test
- void cannot_withdraw_negative_money() {
Account account = new Account();- assertThrows(IllegalArgumentException.class, () -> { account.withdraw(-100); });
- }
- @Test
- void cannot_deposit_negative_money() {
- assertThrows(IllegalArgumentException.class, () -> { account.deposit(-100); });
- }
- }