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.
Inside a list of words, return the longest of them.
def getLongestWord(words):
longest = ""
for w in words:
longest = w if len(w) > len(longest) else longest
return longest
# TODO: Replace examples and use TDD development by writing your own tests
# These are some of the methods available:
# test.expect(boolean, [optional] message)
# test.assert_equals(actual, expected, [optional] message)
# test.assert_not_equals(actual, expected, [optional] message)
# You can use Test.describe and Test.it to write BDD style test groupings
Test.describe("Tests")
Test.assert_equals(getLongestWord(["word1","word11", "word111"]), "word111", "Regular")
Test.assert_equals(getLongestWord([]),"", "Exceptional cases")
Test.assert_equals(getLongestWord(["word"]),"word","Lenght 1")
Given a number, write a function that prints a square with the caracter '*'
def square(n):
l=''
square1=[]
for i in range(n):
l+='*'
for i in range(n):
square1.append(l)
for i in range(n):
print(square1[i])
return square1
# TODO: Given a number, write a function that prints a square with the caracter '*'
# These are some of the methods available:
# test.expect(boolean, [optional] message)
# test.assert_equals(actual, expected, [optional] message)
# test.assert_not_equals(actual, expected, [optional] message)
# You can use Test.describe and Test.it to write BDD style test groupings
test.assert_equals(square(2),['**', '**'])
test.assert_equals(square(3),['***', '***', '***'])
test.assert_equals(square(4),['****', '****', '****', '****'])
test.assert_equals(square(5),['*****', '*****', '*****', '*****', '*****'])
Return the bigger integer
public class BiggerNum{
public static int compare(int a, int b) {
return 0;
}
}
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import org.junit.runners.JUnit4;
// TODO: Replace examples and use TDD development by writing your own tests
public class SolutionTest {
@Test
public void testSomething() {
int a = 10;
int b = 5;
//assertEquals(10, BiggerNum.compare(a, b));
}
}
Write a program that take as imput a string (made of only numbers and letters) and returns the morse code equivalent.
dot='.'
dash='-'
morse = {'a':[dot,dash],'b':[dash,dot,dot,dot],'c':[dash,dot,dash,dot],'d':[dash,dot,dot],'e':[dot],'f':[dot,dot,dash,dot],'g':[dash,dash,dot],'h':[dot,dot,dot,dot],""
'i':[dot,dot],'j':[dot,dash,dash,dash],'k':[dash,dot,dash],'l':[dot,dash,dot,dot],'m':[dash,dash],'n':[dash,dot],'o':[dash,dash,dash],'p':[dot,dash,dash],'q':[dash,dash,dot,dash],""
'r':[dot,dash,dot],'s':[dot,dot,dot],'t':[dash],'u':[dot,dot,dash],'v':[dot,dot,dot,dash],'w':[dot,dash,dash],'x':[dash,dot,dot,dash],'y':[dash,dot,dash,dash],'z':[dash,dot,dot],""
'0':[dash,dash,dash,dash,dash],'1':[dot,dash,dash,dash,dash],'2':[dot,dot,dash,dash,dash],'3':[dot,dot,dot,dash,dash],'4':[dot,dot,dot,dot,dash],'5':[dot,dot,dot,dot,dot],""
'6':[dash,dot,dot,dot,dot],'7':[dash,dash,dot,dot,dot],'8':[dash,dash,dash,dot,dot],'9':[dash,dash,dash,dash,dot]}
def morse_code(msg):
code=''
for i in msg:
if i==' ':
code+=' '
else:
for j in morse[i.lower()]:
code+=j
return code
print(morse_code('1122'))
# TODO: Replace examples and use TDD development by writing your own tests
# These are some of the methods available:
# test.expect(boolean, [optional] message)
# test.assert_equals(actual, expected, [optional] message)
# test.assert_not_equals(actual, expected, [optional] message)
# You can use Test.describe and Test.it to write BDD style test groupings
test.assert_equals(morse_code('sos'),'...---...')
test.assert_equals(morse_code('hello world'),'......-...-..--- .-----.-..-..-..')
test.assert_equals(morse_code('you passed'),'-.-----..- .--.-.......-..')
test.assert_equals(morse_code('is a good day'),'..... .- --.-------.. -...--.--')
Il faut créer une fonction qui s'appelle quiEstLeMeilleurProf et qui retourne la phrase suivante : "Mon prof de programmation Web"
function quiEstLeMeilleurProf(){
return "Mon prof de programmation Web";
}
// PHPUnit Test Examples:
// TODO: Replace examples and use TDD development by writing your own tests
class MyTestCases extends TestCase
{
// test function names should start with "test"
public function testThatSomethingShouldHappen() {
$this->assertEquals("Mon prof de programmation Web", quiEstLeMeilleurProf());
}
}
Il faut créer une fonction qui s'appelle quiEstLeMeilleurProf et qui retourne la phrase suivante : "Mon prof de programmation Web"
function quiEstLeMeilleurProf(){
return "Mon prof de programmation Web";
}
// PHPUnit Test Examples:
// TODO: Replace examples and use TDD development by writing your own tests
class MyTestCases extends TestCase
{
// test function names should start with "test"
public function testThatSomethingShouldHappen() {
$this->assertEquals("Mon prof de programmation Web", quiEstLeMeilleurProf());
}
}
here is the description of the 3 offers
ESSENTIAL : just one device
STANDARD : HD and 2 devices
PREMIUM : UltraHD and 4 devices
Write the code that returns the right offer
using System;
public class Kata
{
public static string GetContract( int numberOfDevices, bool ultraHd, bool hd)
{
string result = "ESSENTIEL";
if (numberOfDevices>2 || ultraHd)
{
result = "PREMIUM";
}
else
{
if (numberOfDevices == 2 || hd)
{
result = "STANDARD";
}
}
return result;
}
}
namespace Solution {
using NUnit.Framework;
using System;
// TODO: Replace examples and use TDD development by writing your own tests
[TestFixture]
public class SolutionTest
{
[Test]
public void TestMethodGetContract4()
{
var actual = Kata.GetContract(4, false, false);
var expected = "PREMIUM";
Assert.AreEqual(expected, actual);
}
[Test]
public void TestMethodGetContract2()
{
var actual = Kata.GetContract(2, false, false);
var expected = "STANDARD";
Assert.AreEqual(expected, actual);
}
[Test]
public void TestMethodGetContract1()
{
var actual = Kata.GetContract(1, false, false);
var expected = "ESSENTIEL";
Assert.AreEqual(expected, actual);
}
[Test]
public void TestMethodGetContractUltraHD()
{
var actual = Kata.GetContract(1, true, false);
var expected = "PREMIUM";
Assert.AreEqual(expected, actual);
}
[Test]
public void TestMethodGetContractHD()
{
var actual = Kata.GetContract(1, false, true);
var expected = "STANDARD";
Assert.AreEqual(expected, actual);
}
}
}
cannot go diagonally
array = [1,1,1,y,1],
[1,1,1,1,1],
[1,1,x,1,1],
[1,1,1,1,1]
here you have to make 3 moves to get from y to x
def distance(array):
y = 0
y1 = 0
for inner_list in range(len(array)):
if "y" in array[inner_list]:
y = inner_list
if "x" in array[inner_list]:
y1 = inner_list
x = array[y].index("y")
x1 = array[y1].index("x")
dist = abs(x -x1) + abs(y-y1)
return dist
array = [1,1,1,"y",1],[1,1,1,1,1],[1,1,"x",1,1],[1,1,1,1,1]
test.assert_equals(distance(array),3)
array = [1,1,1,1,"y"],[1,1,1,1,1],[1,1,"x",1,1],[1,1,1,1,1]
test.assert_equals(distance(array),4)
add the individual digits together.
the function also takes in 3 different integers with the following meaning
0 = add all of them
1 = add only odd numbers
2 = add only even numbers
e.g
add("1234567" , 0) ----> "1234567" = 28
add("1234567" , 1) ----> "1234567" = 16
add("1234567" , 2) ----> "1234567" = 12
def add(string, option):
return 28 #total depending on the option
test.assert_equals(add("1234567" , 0),28)
given a list of lists. each inner list is same size.
they can represent a square or a rectangle.
return information about it.
return its perimeter , area,total number of "*", rectangle/square
s = "*"
array = [[s,s,s,s],[s,s,s,s],[s,s,s,s],[s,s,s,s]]
===> permimeter = 16 ,area = 16, "*" = 16 , "square"
def determine_params(list):
return #its perimeter , area,total number of "*", rectangle/square
# s = "*"
# array = [[s,s,s,s],[s,s,s,s],[s,s,s,s],[s,s,s,s]]
# test.assert_equals(determine_params(array),16,16,16,"square")